Search MXDs with specific dataSource layer using Python

المشرف العام

Administrator
طاقم الإدارة
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,sysimport arcpy.mappingfrom arcpy import envenv.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 mxdFinally, 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.mxdTraceback (most recent call last): File "C:\Users\yaron.KAYAMOT\Desktop\idle.pyw", line 13, in print mxdname, mxdname.pathwayAttributeError: 'unicode' object has no attribute 'pathway'

أكثر...
 
أعلى