Find ArcMap document version with PythonWed 15 April 2015
This post shows how to find the version number of an ArcGIS map document (.mxd) programmatically using Python. It seems that
arcpy does not provide a method to do this itself.
ArcGIS map documents are actually Microsoft OLE2 files (also called Structured Storage, Compound File Binary Format or Compound Document File Format). There is a Python module called
oletools which can read this format, which is available on PyPI.
oletools using pip (from a command prompt):
pip install oletools
The following Python function takes a filename and returns the document version number as a string (e.g.
from oletools.thirdparty import olefile def mxd_version(filename): assert(olefile.isOleFile(filename)) ofile = olefile.OleFileIO(filename) stream = ofile.openstream('Version') data = stream.read().decode('utf-16') version = data.split('\x00') return version
It is possible to access other information about the map document in this way, although most of the data remains in an undocumented proprietary format and is not readable. The
oletools module includes a graphical browser for data in OLE2 files called
This post is based on my answer to a question on GIS.SE.