I know, I know who would want to repair the datasources on an MXD that has not layers in it. Technically not me, however, I was tasked to help some people who have created several empty files amongst a whole mess of other ones in various folders. My Python script runs just fine until it come across an MXD with no data layers, then it errors out saying:
Traceback (most recent call last):
File "D:/Users/Tools/Repair Data Sources/Scripts/repair_mxd_sources_production_2.py", line 45, in <module>
outputMXDname = newmxdname.saveACopy(root + "\\" + inputmxdname.strip(".mxd") + "_Source_Repaired.mxd")
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\_mapping.py", line 828, in saveACopy
self._arc_object.saveACopy(file_name)
AttributeError: MapDocObject: Unable to save. Check to make sure you have write access to the specified file and that there is enough space on the storage device to hold your document.
Not sure why it's having an issue saving an empty file. Is there any way to get it to ignore MXDs with no data? Maybe even ignore ones that have a file size of 5KB or below?