0

I have thousands of shapefiles that I would like to rename, all are currently named "cYYYDDD_Union_Clip_Clip" and I would like to ultimately rename each to "YYYYDDDD_abc")? I've tried using Iterator in ModelBuilder with in-line variable substitution but as I understand both I can only substitute the existing shapefile name (e.g. the best I can do with Iterator and in-line substitution is maintain the input name as the output name). Any one know what I can do to rename multiple shapefiles in an automated fashion?

2 Answers 2

2

I would write a simple Python script utilizing arcpy.da.walk to navigate a folder structure, renaming the Shapefiles. It is easy to make a Model from a working script.

1
  • I think this solution is best if you want to go for re-usability of your script. You want to get the most out of the time spent scripting, right? If you combine arcpy.da.walk with arcpy.Rename_management, you can do this for any data type and any workspace type. Chances are, if your boss asks you to do this once, he or she will ask again, possibly for a different data type. You could even expand it to choose whether you want to rename, copy, or delete by wildcard.
    – RHB
    Commented Mar 25, 2016 at 14:02
0

@klewis gives a good solution. However, as it is just file name changes based on a pattern you want, even simpler, and almost certainly faster because it by-passes ArcGIS altogether, is to write a script (pick your favourite language) to walk the file directory directly. Just make sure you change all files so you catch all the components of the shapefile e.g. .shp, .shx, .prj and so on, but if you apply your script to all files that should happen automatically anyway.

There are loads of examples of how to do this on the 'net and in other Stackexchange sites (e.g. see here or here etc). There's nothing magical about the shapefile and any of the 'standard' solutions will work so long as all parts of the file share the same name (before the extension). By not invoking your GIS, especially Arc, for this simple operation you avoid a huge overhead. If it had been a Geodatabase... well that would have been a very different matter.

Whatever solution you go for, I recommend making a zip archive of your data first though, in case either your process or choice of name proves unfortunate later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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