Closely related to Converting .mxd files that were created with 10.3 to .mxd files that are compatible with 10.1, except I am running ArcGIS 10.4. It should be possible for me to make 10.1 copies of all my 10.4 mxds. Here is my code:
import arcpy, sys, os, string dir = r"D:\Path\To\Maps" outloc = os.path.join(dir, "Compatible_MXDs") version = '10.1' suffix = "_"+ version.replace(".", "") # Get all mxds in this directory arcpy.env.workspace = dir mxdList = arcpy.ListFiles("*.mxd") for file in mxdList: print(file) # mymap.mxd mxd = arcpy.mapping.MapDocument(os.path.join(dir, file)) base = os.path.basename(file) print(base) # ('D:/Path/To/Maps/mymap', '.mxd') base = os.path.splitext(base) + suffix + os.path.splitext(base) mxd.saveACopy(outloc + os.sep + base, version) print(os.path.basename(file) + " has been converted")
But I get the same error:
Traceback (most recent call last): File "MakeMXDsBackwardsCompatible.py", line 21, in <module> mxd.saveACopy(outloc + os.sep + base, version) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\utils.py", line 182, in fn_ return fn(*args, **kw) File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\_mapping.py", line 877, in saveACopy self._arc_object.saveACopy(file_name, version) 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.
I'd rather not use the "File -> Save a Copy -> change mxd version" dialogue for 500 separate mxds over multiple directories.
While my question is also closely related to AttributeError: MapDocObject: Unable to save on mxd.save/saveACopy?, the answers are still not satisfactory for my problem. The relevant (simplified) code:
mxd = arcpy.mapping.MapDocument(r"D:\Path\To\Maps\mymap.mxd") mxd.saveACopy(r"D:\Path\To\Maps\Compatible_MXDs\mymap_101.mxd", '10.1')
Now with regard to that question's answers...
1) I have no mxds with the same name already on disk, nor am I trying to overwrite.
2) I am not attempting to overwrite an mxd file that is already in use. No other scripts are concurrently accessing it. Furthermore nothing changes even after I add
at the end.
3) Again, I am not calling anything like
I have read the documentation.
I have tried rebooting and running my script without starting ArcMap. I don't use an IDE, but use Notepad++ to write my scripts and execute them on my command line with