Solved! Go to Solution.
I know this is an old thread, but here is some code I wrote to do the trick. It can be incorporated into a loop for multiple MXDs.
import os, sys, arcpy, re
mxdFile = "C:\\temp\\map_document.mxd"
mxd101 = '10.1' + u'\u0013'
mxd102 = '10.1' + u'\u0013'
mxd103 = '10.3' + u'\u0014'
mxd104 = '10.4' + u'\u0015'
mxd105 = '10.5' + u'\u0016'
mxd106 = '10.6' + u'\u0017'
mxdList = [mxd101, mxd102, mxd103, mxd104, mxd105, mxd106]
result = []
with open(mxdFile, 'rb') as mxd:
fileContents = mxd.read().decode('latin1')
removedChars = [x for x in fileContents if x not in [u'\xff',u'\x00',u'\x01',u'\t']]
joinedChars = ''.join(removedChars)
for m in mxdList:
location = joinedChars.find(m)
if len(joinedChars[location:location+4]) > 0:
result.append(joinedChars[location:location+4])
print result[0]
>>> mxd.saveACopy("c:/output/base_93.mxd", "9.3")
Thanks but I know that already. I need to save the MXD out to the same version of ArcGIS. So if it's 9.3 I want to save to 9.3 but if it is 9.2 it needs to be saved as 9.2. I notice that if you leave out the version keyword it upgrades the MXD to 10.0.
No, not possible in Python in ArcGIS 10 to tell what release a mapdocument is currently saved as (I'm told possibly at 10.1)
-Dave
Dave,
Assuming you're still out there do you know if this got added to 10.1? I really need that able in a script I'm writing that strips out broken map service datasources.
Thanks
Alas, no.
I did see this strategy listed under the answer section that seems to hold though: http://gis.stackexchange.com/questions/62090/arcpy-method-to-determine-arcmap-document-version
I know this is an old thread, but here is some code I wrote to do the trick. It can be incorporated into a loop for multiple MXDs.
import os, sys, arcpy, re
mxdFile = "C:\\temp\\map_document.mxd"
mxd101 = '10.1' + u'\u0013'
mxd102 = '10.1' + u'\u0013'
mxd103 = '10.3' + u'\u0014'
mxd104 = '10.4' + u'\u0015'
mxd105 = '10.5' + u'\u0016'
mxd106 = '10.6' + u'\u0017'
mxdList = [mxd101, mxd102, mxd103, mxd104, mxd105, mxd106]
result = []
with open(mxdFile, 'rb') as mxd:
fileContents = mxd.read().decode('latin1')
removedChars = [x for x in fileContents if x not in [u'\xff',u'\x00',u'\x01',u'\t']]
joinedChars = ''.join(removedChars)
for m in mxdList:
location = joinedChars.find(m)
if len(joinedChars[location:location+4]) > 0:
result.append(joinedChars[location:location+4])
print result[0]