I work with ArcGIS 10.3 and I try to search a specific layer (with dataSource named "D:\desktop\Project\layers\1.jpg" ) in hundred of mxd's that spread in folder "D:\PROJECTS" and it divided to hundred of sub folders, using python 2.7.8:
import arcpy,os,sys
import arcpy.mapping
from arcpy import env
env.workspace = r"D:\PROJECTS"
for mxdname in arcpy.ListFiles("*.mxd"):
mxd = arcpy.mapping.MapDocument(r"D:\desktop\Project\\" + mxdname)
dfList = arcpy.mapping.ListDataFrames(mxd, "*")
for df in dfList:
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
if lyr.isGroupLayer == True: continue
if lyr.dataSource == r"D:\desktop\Project\layers\1.jpg":
print mxdname, mxdname.pathway
mxd.save()
del mxd
Finally, I want that python will print all the mxd's source name that contain the specific layer I search for. When I run the code I get error:
project1.mxd
Traceback (most recent call last):
File "C:\Users\yaron.KAYAMOT\Desktop\idle.pyw", line 13, in <module>
print mxdname, mxdname.pathway
AttributeError: 'unicode' object has no attribute 'pathway'