1

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)[0] + suffix + os.path.splitext(base)[1] 
    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

del mxd

at the end.

3) Again, I am not calling anything like

mxd.saveACopy(mxd)

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 python MakeMXDsBackwardsCompatible.py

  • To me that message suggests that something, probably an ArcMap instance, is holding a lock over one or more of your mxds. Have you tried rebooting and then running your script from an IDE (without starting ArcMap)? – PolyGeo Feb 23 '17 at 1:28
  • No instances of Arc were open while I tried running this. In the question you linked, the asker failed to pass the proper path parameter in mxd.saveACopy(...). I'm pretty sure I did this right. – Wassadamo Feb 25 '17 at 4:39
  • That question has three answers so to get your question re-opened you will need to edit it to account for why none of them apply to you. To me that message suggests that something is holding a lock over one or more of your mxds. Have you tried rebooting and then running your script from an IDE (without starting ArcMap)? – PolyGeo Feb 25 '17 at 4:52
  • Sorry for not making myself clear. 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 "python MakeMXDsBackwardsCompatible.py" Also I have edited my question to explain why those 3 answers do not help me. Can my question please be reopened? Thanks in advance! – Wassadamo Mar 1 '17 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.