Saturday, 15 October 2016

Looping through list of shapefiles to rename them using ArcPy?



I am trying to upgrade a simple script to list all shapefiles in a folder and if necessary in any folders within and then loop through the list of shapefiles and rename them.


import arcpy

# Set work environment
arcpy.env.workspace = "C:\\Users\\Rachael\\Documents\\Export"

# List shapefiles in folders
shp = arcpy.ListDatasets()

try:

for shp in arcpy.ListDatasets():
if arcpy.Exists("Histori2.shp"):
arcpy.Rename_management("Histori2.shp", "H_BEV_CANS.shp")


No comments:

Post a Comment