I've been tasked with renaming a large amount of raster files within a file geodatabase (ArcGIS style).
I'm taking weather data which has a name format as such: "G"mmddhhhhI'm trying to add a year tag in between the G and month: "G"yyyymmddhhhh
Here is the function that I've written:
# ----------------------------------------------------------------------------- #@timeitdef renameRasters(FGDB): origdir = arcpy.env.workspace arcpy.env.workspace = FGDB for rstr in arcpy.ListRasters("G*"): try: newrstr = "G" + "2014" + rstr.replace("g", "") arcpy.Rename_management(rstr, newrstr) except: print "Failed to rename: " + rstr arcpy.env.workspace = origdir return None# ----------------------------------------------------------------------------- #This function works fine for a small to medium amount of rasters within a FGDB and takes about 1.5 seconds per raster renamed. I run into issues when there are a large number of files to be renamed. 1,200 files takes > 10 hours. At the same rate as the smaller raster sets this should take < 1 hour...
Does anyone have an idea on how to make this process go faster?
If not I'll set it up to run over the weekend.
I should mention that I am using ArcGIS 10.2.2.
أكثر...
I'm taking weather data which has a name format as such: "G"mmddhhhhI'm trying to add a year tag in between the G and month: "G"yyyymmddhhhh
Here is the function that I've written:
# ----------------------------------------------------------------------------- #@timeitdef renameRasters(FGDB): origdir = arcpy.env.workspace arcpy.env.workspace = FGDB for rstr in arcpy.ListRasters("G*"): try: newrstr = "G" + "2014" + rstr.replace("g", "") arcpy.Rename_management(rstr, newrstr) except: print "Failed to rename: " + rstr arcpy.env.workspace = origdir return None# ----------------------------------------------------------------------------- #This function works fine for a small to medium amount of rasters within a FGDB and takes about 1.5 seconds per raster renamed. I run into issues when there are a large number of files to be renamed. 1,200 files takes > 10 hours. At the same rate as the smaller raster sets this should take < 1 hour...
Does anyone have an idea on how to make this process go faster?
If not I'll set it up to run over the weekend.
I should mention that I am using ArcGIS 10.2.2.
أكثر...