I have GDB files located in many sub-Folders and sub-sub-Folders. All Sub Folders are located in one large directory i asked it for layer file in Add multiple Layer files in subdirectories to mxd using python I use this code:
import arcpy
import os
workspace = r"C:\Project\layers"
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]
walk = arcpy.da.Walk(workspace, datatype="Layer")
for dirpath, dirnames, filenames in walk:
for filename in filenames:
arcpy.mapping.AddLayer(df, arcpy.mapping.Layer(os.path.join(dirpath, filename)))
print filename
mxd.save()
del mxd
How can i do it for GDB files ?
No comments:
Post a Comment