Is there a way with ArcPy to identify the version of a Map Document (MXD). I am working on a solution to inventory our MXD's and would like to know if a document is 8.1, 9.2, 10.0, etc.

I am currently using ArcGIS 10.0, but if there is an update in 10.1 that does not exist in 10.0, I would appreciate hearing that, too.

I see there is a previous question of How can you find ArcGIS version programatically?, but it references all ArcObjects solutions (which I suppose I could call from python, but I would prefer not to).

  • 2
    I think this might need an enhancement request for a read-only version property to be added to the MapDocument object. If you find/create one then link to it here and I will vote for it. – PolyGeo May 28 '13 at 22:33
  • There is a version control ArcGis Idea. (well, 3 merged into one) – gm70560 May 29 '13 at 0:50
  • I copied your script, modified it slightly for my environment and ran it on some of my files, but some of the files did not return a version even though I know they were saved in 9.3 or 10.0. I'm not sure if broken data sources would mess up your script. – user23294 Oct 25 '13 at 13:55
  • Related: gisnuts.com/terra/blog/2014/02/24/… An excellent find by @danjurgell in a comment on a follow up question to the accepted answer here. Based on that blog post, there is no 100% reliable way to do this because the info just isn't stored in the file in a predictable manner. Both answers here will work some of the time but not all of the time. – Chris W Jun 11 '15 at 4:02

I know this question is a few months old, but I'm posting this in case it helps others. I developed this kludge to parse version numbers from MXD documents. It basically reads the first 4000 or so characters of an MXD document and searches for a version number. I tested with MXD versions 9.2, 9.3, 10.0, and 10.1.

import re

def getMXDVersion(mxdFile):
    matchPattern = re.compile("9.2|9.3|10.0|10.1|10.2")
    with open(mxdFile, 'rb') as mxd:
        fileContents = mxd.read().decode('latin1')[1000:4500]
        removedChars = [x for x in fileContents if x not in [u'\xff',u'\x00',u'\x01',u'\t']]
        joinedChars = ''.join(removedChars)
        regexMatch = re.findall(matchPattern, joinedChars)
        if len(regexMatch) > 0:
            version = regexMatch[0]
            return version
            return 'version could not be determined for ' + mxdFile

Here is an example of scanning a folder for mxd files and printing the version and names

import os
import glob
folder = r'C:\Users\Administrator\Desktop\mxd_examples'
mxdFiles = glob.glob(os.path.join(folder, '*.mxd'))
for mxdFile in mxdFiles:
    fileName = os.path.basename(mxdFile)
    version = getMXDVersion(mxdFile)
    print version, fileName

Which returns this:

10.0 Arch_Cape_DRG.mxd
9.2 class_exercise.mxd
9.3 colored_relief2.mxd
10.1 CountyIcons.mxd
10.0 DEM_Template.mxd
9.2 ex_2.mxd
10.0 nairobimap.mxd
10.0 slope_script_example.mxd
10.1 TrailMapTemplateBetter.mxd
10.0 Wickiup_Mountain_DEM.mxd
  • This is very cool! Very useful. Now can we do this with layers and geodatabases as well? – Mike Oct 25 '13 at 19:27
  • This is pure awesome! – dchaboya Nov 21 '13 at 0:02
  • Work weel before 10.4 I have analyse mxd with Hexa reader and version position have change (it is after path before and today it is before path and add "Build Number" prefix words value next is ( With 10.3.1 I have 10.3.6 in hexa value part – GeoStoneMarten May 3 '16 at 10:19
  • 1
    this doesnt seem to work for me, checking for 10.6.1 mxds that have been resaved to 10.2.2 (all return 'version could not be determined') ... have there been any updates in mxd docs to integrate into this script? – JasonBK Sep 18 '19 at 17:50

The function below is based on Ryan's idea, but is a little more direct. ArcGIS map documents are actually OLE documents, which can be parsed with the oletools module (available on pypi: https://pypi.python.org/pypi/oletools). The function opens the file and reads the version string. Tested with 9.0, 9.3, 10.1 and 10.3, but should work with anything (not sure about 3.x...).

from oletools.thirdparty import olefile

def mxd_version(filename):
    ofile = olefile.OleFileIO(filename)
    stream = ofile.openstream('Version')
    data = stream.read().decode('utf-16')
    version = data.split('\x00')[1]
    return version

if __name__ == '__main__':
    import sys
  • 1
    That's a great function, too. The only hesitation I would have against using this function is that it requires the user to download/install a third party library (oletools) which in some organizations users may not be able to do. – RyanKDalton Apr 16 '15 at 17:50
  • I only get one vote, but this will work in cases where the other answer doesn't. – DWynne Jun 10 '15 at 22:47
  • Snorfalorpagus it work well until 10.3 but for 10.4 there is an other stream key 'Mx Document Version Info' with full build number version. I checked with different version of arcgis and my last version return – GeoStoneMarten May 3 '16 at 11:23
  • Interesting. I've not upgraded to 10.4 yet. Could you share a blank mxd for me to see? – Snorfalorpagus May 3 '16 at 11:48
  • 1
    @GeoStoneMarten Thanks. I've looked at the document you sent. It seems to work with the original code - I don't see the "Mx Document Version Info" stream? – Snorfalorpagus May 3 '16 at 14:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.