Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I apologize for crossposting against the ESRI geoprocessing forum, but it seems like this one gets answers. I'd like to have a modified append tool (ArcToolbox) that takes multiple shapefiles with point attribute data, and copies the inputted shapefile's name(s) to a "filename" attribute column, and then appends it to a target dataset. That way I can track where the data came from. The only way I can think to do this is something along the lines of the following:

for each shp in featureclasses:
  outFeatureClass = os.path.join("C:\GIS\Scripts\temp\temptrks", shp.strip(".shp"))
  arcpy.CopyFeatures_management(shp, outFeatureClass)
  arcpy.AddField_management(outFeatureClass, "filename", "TEXT", "","", "254")
  arcpy.CalculateField_management(outFeatureClass, "filename", str(shp), "PYTHON")

Then perform the append for each file in the new workspace.

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).

I have two questions:

  1. Is there an easier/better way to perform the task?
  2. If not, what should I set the parameter type to (Multiple Value is not a selection).
share|improve this question

In your ArcToolbox tool properties I'd set the parameter to a FeatureLayer/FeatureDataset with MultiValue=Yes and use some code like the following to get the filename:

for shp in featureclasses.split(';'):
    dsc = arcpy.Describe(shp)
    filename=dsc.CatalogPath #unicode is returned
share|improve this answer
Right on! Thank you so much, Luke. I'll try it out. – RKK Nov 18 '11 at 0:50
Also, just to save yourself the headache of having to code and cleanup all those temporary datasets, consider copying the data into an [in_memory layer][1]. This 1) will be faster than writing it to disk and 2) automatically clean itself up. Just replace your "outFeatureClass" line of code with "outFeatureClass = "in_memory\tmpSHP".… – RyanDalton Nov 18 '11 at 19:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.