AnsweredAssumed Answered

Store relative path for map documents based on ArcGIS Desktop Version

Question asked by brianmcleer on Dec 1, 2017
Latest reply on Dec 2, 2017 by rvburton

From a prior posting here, I was looking for a solution on how to turn the relative path on in batch. The solution generated will grab any MXD in a root folder and enable the relative paths to be turned on in any sub folder using this code:


import os
from glob import glob
import arcpy

PATH = r'C:\Users\mclbr\Desktop\GIS_Maintenance'
arcpy.env.workspace = PATH

result = [y for x in os.walk(PATH) for y in glob(os.path.join(x[0], '*.mxd'))]
for map in result:  # map will be complete path to map file
    print "Processing: {}".format(map) # keep track of what's happening
    mxd = arcpy.mapping.MapDocument(map)
    #set relative paths property
    mxd.relativePaths = True
    #save map document change


One issue that I have come across is that we have users on 10.2.2 and users on 10.3.1. The code above works on 10.3.1, but when run it updates all 10.2.2 MXDs to 10.3.1. The other issue is that when run on a 10.2.2 machine, the script will fail once it reaches an MXD that was last saved in 10.3.1.


I am taking a shot in the dark, but would anyone know of a way to create code that will only select versions of ArcGIS Desktop for version 10.2.x, then one for 10.3.x? 


If that is possible, I would run the routine on a 10.3.1 machine and insert the code to only update MXDs that are a 10.3.1 document, and do the same for the 10.2.2 machine and documents.