Wednesday, 4 April 2018

arcpy - Add multiple GDB files in subdirectories to mxd using python


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

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...