Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using python, how can one save all layers in the Arcmap (v10) table of contents pane to layer files on disk?

share|improve this question
The arcpy.mapping module documentation should have examples on how to do this. – blah238 Nov 3 '11 at 0:53
Hello I'm trying to do the same thing but I have and error with layer from server, how can I pick only .shp files in my mxd? Thanks a lot Luca – Luca Moiana Jun 14 '12 at 14:07
Hi @Luca, I'm not sure. The exact error message would be likely useful in figuring that out. Might be worth posting as a separate question? – matt wilkie Jun 14 '12 at 16:16
up vote 5 down vote accepted

Untested since I'm not in front of ArcGIS at the moment, but you should be able to use the Layer.saveACopy(path) method. For example:

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
    lyr.saveACopy( + ".lyr")
share|improve this answer
that works, thank you! Two caveats: env.workspace is ignored, the layer files are saved in the same folder as the .mxd, and group layers are ignored (though their contents are still saved, individually) – matt wilkie Nov 3 '11 at 21:14
glad to hear it! Strange that it doesn't export group layers though. – om_henners Nov 6 '11 at 4:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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