This seems like a simple problem, but I have not found a way to accomplish it. I am writing a script that needs to record the paths of everything inside of a geodatabase to a text file, and later copy those files to a new location and zip them up.

I have been able to use arcpy.ListFeatureClasses to grab feature classes, and arcpy.ListRasters, and arcpy.ListDatasets, but how do I obtain a list of, say, Address Locators in my gdb? I haven't found a way to do it with arcpy. There should be a simple function that lists all of the contents of a geodatabase. Is there one I'm missing? Or is there any other way to accomplish this in python?

  • 1
    So is the mission here to copy the entire geodatabase (is it a file geodatabase) to another location and zip it up, or is there more (like the writing of the paths out to a text file)? Feb 15, 2012 at 2:57
  • 1
    I addressed this in my question. I said "I am writing a script that needs to record the paths of everything inside of a geodatabase to a text file". Basically, I'm copying certain contents of a gdb (sometimes the entire thing) to an identically-named gdb which is then zipped up and given to one of our customers as a data update.
    – Tanner
    Feb 15, 2012 at 20:18
  • The text file keeps track of which items were put into the zip file.
    – Tanner
    Feb 15, 2012 at 21:40

2 Answers 2


If your goal is simply copying a geodatabase with (most?) everything intact, you could use Copy_management to copy it to a file geodatabase, which you could then zip up using the Python zipfile module. There are also geoprocessing tools for geodatabase replication but I am not sure if address locators are included.

I am not aware of a way to list address locators with arcpy. You could suggest it on ArcGIS Ideas.

The last possibility I would suggest -- and this is definitely in the "any other way" category due to its complexity -- is to export the geodatabase to an ESRI XML Workspace document and parse it with Python's ElementTree XML API or lxml.

Currently there is no built-in way in arcpy to export an XML workspace document -- that's supposedly coming in 10.1 according to this ArcGIS Ideas post. However, you could write an ArcObjects command line application (like this one) and call it from Python using the subprocess module. Again I am not sure if things like address locators are included in the XML output though.


If you're copying an entire file geodatabase, the Robocopy command is perfect, and can even be used while the source gdb is in use as long as you exclude the lock files. It is built in to Windows, so can just be called from the command prompt.

robocopy path/to/source/gdb path/to/dest/gdb /s /xf *.lock

There are many more available options, but /mt is particularly useful as it copies on multiple threads to save time.

If you're only copying part of the geodatabase, it can actually be quicker to copy the whole thing, then use Delete_management to remove the feature classes you don't want. I've found the threshold can be as low as 1/3 of the database, i.e. for a database of 1200 items, if you want to copy 400, duplicate database then delete 800 is quicker than just copying the 400 you want.

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.