import arcpy, os path = r"H:\Plans\GIS Plans\2003" f = open('BrokenMXD2003.csv', 'w') f.write("Type, File Path, Layer, Broken Path" + "\n") for root, dirs, files in os.walk(path): for fileName in files: basename, extension = os.path.splitext(fileName) if extension == ".mxd": fullPath = os.path.join(root, fileName) mxd = arcpy.mapping.MapDocument(fullPath) brknMXD = arcpy.mapping.ListBrokenDataSources(mxd) for brknItem in brknMXD: lyrList = arcpy.mapping.ListLayers(mxd) f.write("MXD, " + fullPath + ", " + brknItem.name) if brknItem.supports("dataSource"): f.write(", " + brknItem.dataSource + "\n") else: f.write("\n") f.close() print "Script Completed"
try: brokenItem.supports("dataSource") write dataSource except AttributeError: write ... # something
Looks like two threads were merged? Not seeing a reason.
Thank you i will try this in the next coming weeks and report back my findings.
ok so I tired this. here is my script. it still never got past the first three mxd's with the last one having a broken table source in it.
yes yes I can fix that table... but I need this to walk thru an entire F: and tell me where all and any broken sources are... even if it is just noting " hey there is a broken source here"
Hi Lela,
I have a script that will eventually be released with my Python addin, but this script, listing of broken links, works. It gets around all the tables, and other strange things. As is, you should only have to change theWorkspace to a folder you want to test. Let the rest go to default until you understand what it does.
I've been able to let is run on a folder/subfolders for about 14 hours ....looked at 2217 mxd's, found 51k+ broken linkjs, of which about 3k are broken. Many, like "groups" are list, and then can be ignored. I'm working on the "repair" script, but keep running into the 10.3.1 to older version Addin compatibility (and it's driving me a bit batty). Give this a try (use a test area to see what it does) If you don't put anything for the inFile parameter, it only writes log files. I'll include a couple utility files that will need to be in the same folder....or in your python bin.
I attached them in a zip rather than posting the script. I'll be out for a couple hours, but if you have questions or problems, I can help later today.
Thank you. I am interested to see the repair script as that is my goal as well. to repair some of the broken sources. I know that some I will have to manually repair but if I can identify all broken sources and repair like 50 % of them
even that is better than manually opening each one.
I'm still working on getting a few more of the anomalies worked out. I have a variety of broken sources (coverages or all types, shapes, SDE) that are having to change....some to different types. I will post when it's complete, but not ready to release yet....a few too many things I still need to muddle thru.