Skip to main content
2 of 2
added 4 characters in body
Marcelo Villa
  • 6k
  • 2
  • 20
  • 39

My Arcmap 10.7.1 does not recognize .GLOB but I found another solution. Thank you everybody for your help.

import arcpy, os
import arcpy.mapping as mapping
layer = mapping.Layer(r"C:\PATH_TO_LAYER FILE")
for root, dirs, files in os.walk(r"c:\Users\jcook\Desktop\Batch"):#I have folder named Batch on desktop
    for f in files:
        if f.endswith(".mxd"):
            mxd = root + '\\' + f
            mxd_doc = mapping.MapDocument(mxd)
            df = mapping.ListDataFrames(mxd_doc)[0]
            mapping.AddLayer(df, layer, "TOP") 
            mxd_doc.save()
JohnP
  • 11
  • 2