I'm trying to export ALL layers from the table of contents from a map document but I get the following error:
Runtime error Traceback (most recent call last): File "", line 14,
in File "c:\program files
(x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 2434, in
CopyFeatures raise e ExecuteError: ERROR 000210: Cannot create output
C:\Users\jnmiller\Desktop\Global_Map.mxd\New_Shapefile.shp Failed to execute
(CopyFeatures).
Python Code:
import os, arcpy
infolder = "C:\Users\jnmiller\Desktop\Global_Map.mxd"
outfolder = "C:\EnterpriseFolder\NEO"
#Get name of vector layers in the TOC
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd)[0]
layers = [f.name for f in arcpy.mapping.ListLayers(mxd, "*", df) if
f.isFeatureLayer]
for layer in layers:
#Join output infolder to layer name and append .shp
outfolder = os.path.join(infolder, "{}.shp".format(layer))
arcpy.CopyFeatures_management(layer, outfolder)
Best Answer
With this:
You are trying to copy the features to
Which is not a folder.
I Think this is what you want: