My ArcMap verison is 10.6. The purpose is to add a wetland shapefile to multiple MXDs. It doesn't work and the error said the addLayer is not defined. My script is below.
Does anyone have an idea?
import arcpy,os arcpy.env.workspace = ws = r"C:\Users\Rachel\Desktop\Example\Wetland.shp" wetland = r"C:\Users\Rachel\Desktop" mxd_list = arcpy.ListFiles("*.mxd") for mxd in mxd_list: current_mxd = arcpy.mapping.MapDocument(os.path.join(ws, mxd)) dFrame = arcpy.mapping.ListDataFrames(current_mxd, "Main Map") addLayer = arcpy.mapping.Layer(wetland) arcpy.mapping.AddLayer(dFrame, addLayer) current_mxd.save() print("done") del mxd_list