<?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: Getting the input file name in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/getting-the-input-file-name/m-p/505019#M16784</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I wanted to clarify my thought process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Need to use a for structure so that each input feature class is taken in turn
for each shp in featureclasses:
&amp;nbsp; #Get the name of the feature class
&amp;nbsp; outFeatureClass = os.path.join("C:\GIS\Scripts\temp\temptrks", shp.strip(".shp"))
&amp;nbsp; #Copy and past the feature class to the temporary workspace, to preserve original
&amp;nbsp; arcpy.CopyFeatures_management(shp, outFeatureClass)
&amp;nbsp; #Add filename field to the copy
&amp;nbsp; arcpy.AddField_management(outFeatureClass, "filename", "TEXT", "","", "254")
&amp;nbsp; #Calculate the filename attribute from the file name
&amp;nbsp; arcpy.CalculateField_management(outFeatureClass, "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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; str(shp), "PYTHON")
#Then append each feature class, probably with another for each&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems a little lengthy, and I'm thinking there's got to be an easier way to capture the filename.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:09:37 GMT</pubDate>
    <dc:creator>RussellKallstrom</dc:creator>
    <dc:date>2021-12-11T22:09:37Z</dc:date>
    <item>
      <title>Getting the input file name</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/getting-the-input-file-name/m-p/505018#M16783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi folks-&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need help thinking something through. Basically what I'd like is to have a modified append tool that not only appends multiple the point attribute data, but also "pastes" the inputted shapefile's name(s) to a filename attribute column.&amp;nbsp; That way I can track where the data came from.&amp;nbsp; The only way I can think to do this is something along the lines of the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;for each shp in featureclasses:
&amp;nbsp; outFeatureClass = os.path.join("C:\GIS\Scripts\temp\temptrks", shp.strip(".shp"))
&amp;nbsp; arcpy.CopyFeatures_management(shp, outFeatureClass)
&amp;nbsp; arcpy.AddField_management(outFeatureClass, "filename", "TEXT", "","", "254")
&amp;nbsp; arcpy.CalculateField_management(outFeatureClass, "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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; str(shp), "PYTHON")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I'd like to append it to a target dataset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I'd like to do is be able to have a user drag and drop multiple shapefiles from multiple directories into a Multiple Value input box (like that in the Append tool).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My questions are two:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Is there an easier/better way?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) If not, to what do I set the parameter type (Multiple Value is not a selection).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;RK&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 20:06:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/getting-the-input-file-name/m-p/505018#M16783</guid>
      <dc:creator>RussellKallstrom</dc:creator>
      <dc:date>2011-11-14T20:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Getting the input file name</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/getting-the-input-file-name/m-p/505019#M16784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I wanted to clarify my thought process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Need to use a for structure so that each input feature class is taken in turn
for each shp in featureclasses:
&amp;nbsp; #Get the name of the feature class
&amp;nbsp; outFeatureClass = os.path.join("C:\GIS\Scripts\temp\temptrks", shp.strip(".shp"))
&amp;nbsp; #Copy and past the feature class to the temporary workspace, to preserve original
&amp;nbsp; arcpy.CopyFeatures_management(shp, outFeatureClass)
&amp;nbsp; #Add filename field to the copy
&amp;nbsp; arcpy.AddField_management(outFeatureClass, "filename", "TEXT", "","", "254")
&amp;nbsp; #Calculate the filename attribute from the file name
&amp;nbsp; arcpy.CalculateField_management(outFeatureClass, "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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; str(shp), "PYTHON")
#Then append each feature class, probably with another for each&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems a little lengthy, and I'm thinking there's got to be an easier way to capture the filename.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:09:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/getting-the-input-file-name/m-p/505019#M16784</guid>
      <dc:creator>RussellKallstrom</dc:creator>
      <dc:date>2021-12-11T22:09:37Z</dc:date>
    </item>
  </channel>
</rss>

