Hi,
I work with ArcGIS 10.3 and I try to search a specific layer (with data Source 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. I using python 2.7.8:
import arcpy,os,sys
import arcpy.mapping
from arcpy import env
env.workspace = r"D:\desktop\Project"
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:
<SPAN class="pln" style="color: #000000;">project1</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">mxd<BR /><BR /></SPAN><SPAN class="typ" style="color: #2b91af;">Traceback</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;">(</SPAN><SPAN class="pln" style="color: #000000;">most recent call last</SPAN><SPAN class="pun" style="color: #000000;">):</SPAN><SPAN class="pln" style="color: #000000;"><BR /> </SPAN><SPAN class="typ" style="color: #2b91af;">File</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="str" style="color: #800000;">"C:\Users\yaron.KAYAMOT\Desktop\idle.pyw"</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="pln" style="color: #000000;"> line </SPAN><SPAN class="lit" style="color: #800000;">13</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="kwd" style="color: #00008b;">in</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="pun" style="color: #000000;"><</SPAN><SPAN class="pln" style="color: #000000;">module</SPAN><SPAN class="pun" style="color: #000000;">></SPAN><SPAN class="pln" style="color: #000000;"><BR /> </SPAN><SPAN class="kwd" style="color: #00008b;">print</SPAN><SPAN class="pln" style="color: #000000;"> mxdname</SPAN><SPAN class="pun" style="color: #000000;">,</SPAN><SPAN class="pln" style="color: #000000;"> mxdname</SPAN><SPAN class="pun" style="color: #000000;">.</SPAN><SPAN class="pln" style="color: #000000;">pathway<BR /></SPAN><SPAN class="typ" style="color: #2b91af;">AttributeError</SPAN><SPAN class="pun" style="color: #000000;">:</SPAN><SPAN class="pln" style="color: #000000;"> </SPAN><SPAN class="str" style="color: #800000;">'unicode'</SPAN><SPAN class="pln" style="color: #000000;"> object has no attribute </SPAN><SPAN class="str" style="color: #800000;">'pathway'</SPAN>
Doe's anyone have a solution for this issue?
For clarity, i ask it in arcpy - Search MXDs with specific dataSource layer using Python - Geographic Information Systems Stack Exchange
Thanks