<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: arcpy examples for multiple files in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683890#M52938</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From the horses mouth, 2.7.x in all likelihood.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/24523-Python-version-10.1?p=82222#post82222"&gt;http://forums.arcgis.com/threads/24523-Python-version-10.1?p=82222#post82222&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2011 13:25:25 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2011-06-15T13:25:25Z</dc:date>
    <item>
      <title>arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683884#M52932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can not seem to pick up the basics in using arcpy to read in multiple files and then output multiple files.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can get each process to work on one file (at this stage usually spatial analyst tools) but need help reading in multiple files, executing the process and then outputting the files somewhere. And all of the examples on the ArcGIS10 resource center shows examples with single files. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a (free) tutorial or a place with lots of examples where they use different tools on multiple files. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2011 02:46:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683884#M52932</guid>
      <dc:creator>SarahBurns</dc:creator>
      <dc:date>2011-06-14T02:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683885#M52933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A fairly broad question, but I thinking looping is what you are looking for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://diveintopython.org/file_handling/for_loops.html"&gt;http://diveintopython.org/file_handling/for_loops.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are having trouble with the basics, my suggestion would be to start at the basics and take the arcpy processing portions out, they can complicate testing if you don't have a firm grip on what python is toiling on about. In place of whatever arcpy function you are calling, do a print statement on the variables that would have been passed into the tool so you see how variables are being passed/manipulated. That's how I learned python, anyway.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The rest of the tutorials on the dive into python page are very good as well.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2011 14:12:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683885#M52933</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-06-14T14:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683886#M52934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is a piece of code I use a lot for shapefiles and raster files.&amp;nbsp; Let me know if you would like more info.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import os, arcpy

# Input Folder
inputFolder = r"yourfolderpath"

# Output Folder
outputFolder = r"youroutfolderpath"

for inputFilename in os.listdir(inputFolder) :
&amp;nbsp;&amp;nbsp;&amp;nbsp; if inputFilename.endswith('.shp') :
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inputPath = os.path.join(inputFolder, inputFilename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outputPath = os.path.join(outputFolder, inputFilename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Clip_analysis(ENTER PARAMETERS)

print "End of processing."
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import os, arcpy
from arcpy import env

# Input Folder
inputFolder = r"yourfolderpath"
env.workspace = inputFolder

# Output Folder
outputFolder = r"youroutfolderpath"

rasterList = arcpy.ListRasters("", "GRID")

for raster in rasterList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; inputPath = os.path.join(inputFolder, raster)
&amp;nbsp;&amp;nbsp;&amp;nbsp; outputPath = os.path.join(outputFolder, raster)

print "End of processing."
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good Luck!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lacey&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:45:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683886#M52934</guid>
      <dc:creator>LaceyMason</dc:creator>
      <dc:date>2021-12-12T04:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683887#M52935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Which type of files are you trying to open? mxd's? raster's? layers? etc? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to loop through mxd files, this is a common approach&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
folderPath = r"C:\your mxd location"

# Loop through each folder in the directory to find files containing the extension ".mxd", open each one and process

for filename in glob.glob(os.path.join(folderPath, "*.mxd")):

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fullpath = os.path.join(folderPath, filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.isfile(fullpath):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; basename, filename2 = os.path.split(fullpath)

# At this point, "mxd" is now the variable containing your map document, use that to process whatever it is you're looking to process within each map....
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:45:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683887#M52935</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-12-12T04:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683888#M52936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for your feedback.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to work through python programming:an introduction to computer science by John Zelle&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;as I would like to learn python 3 (since I am a beginner anyway I might aswell learn the latest version of python)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but I feel that I pick things up quicker if I actually use it and see examples. I agree though, I need the very basics to understand what I am doing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes Lacey Mason I would love some more examples. I am currently working mainly with rasters but will eventually be dealing with polygons. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks again&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2011 23:53:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683888#M52936</guid>
      <dc:creator>SarahBurns</dc:creator>
      <dc:date>2011-06-14T23:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683889#M52937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Python 3 doesnt work with ArcGIS. The latest version of python, 3.x, has a number of syntax changes that would reuire over hauls of code written in 2.x. Esri decided to go with 2.6 for v10 and I heard is going to ship 2.7 with v10.1. If you plan to do a lot of ArcGIS programming I would study up on 2.x&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2011 12:01:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683889#M52937</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2011-06-15T12:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683890#M52938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From the horses mouth, 2.7.x in all likelihood.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/24523-Python-version-10.1?p=82222#post82222"&gt;http://forums.arcgis.com/threads/24523-Python-version-10.1?p=82222#post82222&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2011 13:25:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683890#M52938</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-06-15T13:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683891#M52939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thanks, but surely they will move to Python3 soon enough/eventually?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I should just try and stay on top of both! that will be easy enough....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2011 22:09:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683891#M52939</guid>
      <dc:creator>SarahBurns</dc:creator>
      <dc:date>2011-06-15T22:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683892#M52940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Python 3.x acceptance has been slow in general, so I wouldn't expect it to be forced on ArcGIS users anytime soon, simply due to the lack of support from a large number of other popular Python libraries and frameworks (&lt;/SPAN&gt;&lt;A href="https://docs.djangoproject.com/en/1.2/faq/install/#can-i-use-django-with-python-3"&gt;example&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would stick to learning Python 2.x -- once you have mastered that, the transition to 3.x, if and when it ever becomes required for ArcGIS, will be much easier.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2011 22:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683892#M52940</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2011-06-15T22:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683893#M52941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thanks for the response. I think I will take your advice.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2011 02:22:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683893#M52941</guid>
      <dc:creator>SarahBurns</dc:creator>
      <dc:date>2011-06-16T02:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy examples for multiple files</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683894#M52942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;slburns - I have a lot of examples, if you could send me your email address I can send a bunch of my stand along scripts for you to look through.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2011 18:58:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-examples-for-multiple-files/m-p/683894#M52942</guid>
      <dc:creator>LaceyMason</dc:creator>
      <dc:date>2011-06-20T18:58:30Z</dc:date>
    </item>
  </channel>
</rss>

