Skip to main content
added 4 characters in body
Source Link
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()

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()

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()

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()
Source Link
JohnP
  • 11
  • 2

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()