I've been tasked with renaming a large amount of raster files within a file geodatabase (using ArcGIS 10.2.2).

I'm taking weather data which has a name format as such: "G"mmddhhhh I'm trying to add a year tag in between the G and month: "G"yyyymmddhhhh

Here is the function that I've written:

# ----------------------------------------------------------------------------- #
def renameRasters(FGDB):
    origdir = arcpy.env.workspace
    arcpy.env.workspace = FGDB

    for rstr in arcpy.ListRasters("G*"):
            newrstr = "G" + "2014" + rstr.replace("g", "")
            arcpy.Rename_management(rstr, newrstr)

            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?

  • I wonder if instead of using arcpy if it would be more efficient to modify the actual folder/file names with os.walk ?
    – GISHuman
    Aug 20, 2014 at 17:40
  • 1
    What specific issues are you running into on larger FGDBs? Is the FGDB on a local filesystem or on a networked one? Have you tried putting a delay ( time.sleep(0.5) ) into the loop to prevent race conditions? (Please update the question)
    – Vince
    Aug 20, 2014 at 17:43
  • 5
    os.walk will not work on FGDBs. Instead, if you have at least ArcGIS 10.1 service pack 1, you could try using arcpy.da.Walk. It might be faster. Very large lists in python can be memory intensive.
    – Fezter
    Aug 21, 2014 at 0:37
  • 3
    @Fezter, a list of 1200 files in a FGDB won't be very memory intensive. I've used ListRaster() over a parent directory containing ~100 folders and ~30k images, and it completed in a few minutes. Listing the images probably isn't the bottleneck.
    – Paul
    Aug 21, 2014 at 2:25
  • 3
    Apart from simplifying your rename function to newrstr = rstr.replace("G", "G2014") (assuming they are capital G), I just tried running essentially the same script and it cranked a local drive FGDB in 0.7 seconds each feature class, running it in ArcCatalog. It spins up a separate task for each rename, so that might be the issue.
    – spg
    Jul 10, 2015 at 23:25

1 Answer 1


I recently had a similar task. It seems arcpy.Rename_management() is slow by nature. I did find that adding arcpy.env.addOutputsToMap = False improves performance ever-so-slightly, as ArcMap doesn't have to spend time drawing the rasters as they're added. Alternatively, the script can be run from ArcCatalog.

I added additional timers and print statements to your script (see example outputs below. My Virtual machine was running extra slow, so times are exagerated):

import arcpy, timeit

arcpy.env.addOutputsToMap = False

def renameRasters(FGDB):
    origdir = arcpy.env.workspace
    arcpy.env.workspace = FGDB

    for rstr in arcpy.ListRasters("*"):
        rstrTimerStart = timeit.default_timer()
            newrstr = "G" + "2015" + rstr.replace("G2015G2014", "G2015")
            arcpy.Rename_management(rstr, newrstr)
            printMsg = "--Raster renamed " + newrstr + ". Timer: "

        except Exception as e:
            printMsg = "--Rename failed: " + rstr + ". Exception: " + str(e).replace("\n","") + "  Timer: "
        rstrTimerStop = timeit.default_timer()
        print printMsg + str(rstrTimerStop - rstrTimerStart) + " seconds."

    arcpy.env.workspace = origdir
    return None

start = timeit.default_timer()

print "Begin Raster Rename Function"
print "Raster Rename Function Complete"

stop = timeit.default_timer()
print "Took " + str(stop - start) + " seconds to complete."

addOutputsToMap = True, From network drive

arcpy.env.addOutputsToMap = True, From network drive

addOutputsToMap = False, From network drive

arcpy.env.addOutputsToMap = False, From network drive

addOutputsToMap = False, From local drive

arcpy.env.addOutputsToMap = False, From local drive

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.