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:
<SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">import</SPAN> os
<SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">from</SPAN> glob <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">import</SPAN> glob
<SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">import</SPAN> arcpy
PATH <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit; font-size: 14px;">=</SPAN> r<SPAN class="" style="color: #669900; border: 0px; font-weight: inherit; font-size: 14px;">'C:\Users\mclbr\Desktop\GIS_Maintenance'</SPAN>
arcpy<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>env<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>workspace <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit; font-size: 14px;">=</SPAN> PATH
result <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit; font-size: 14px;">=</SPAN> <SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">[</SPAN>y <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">for</SPAN> x <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">in</SPAN> os<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>walk<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN>PATH<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">)</SPAN> <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">for</SPAN> y <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">in</SPAN> glob<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN>os<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>path<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>join<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN>x<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">[</SPAN><SPAN class="" style="color: #990000; border: 0px; font-weight: inherit; font-size: 14px;">0</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">]</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">,</SPAN> <SPAN class="" style="color: #669900; border: 0px; font-weight: inherit; font-size: 14px;">'*.mxd'</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">]</SPAN>
<SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">for</SPAN> map <SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">in</SPAN> result<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">:</SPAN> <SPAN class="" style="color: slategray; border: 0px; font-weight: inherit; font-size: 14px;"># map will be complete path to map file</SPAN>
<SPAN class="" style="color: #0077aa; border: 0px; font-weight: inherit; font-size: 14px;">print</SPAN> <SPAN class="" style="color: #669900; border: 0px; font-weight: inherit; font-size: 14px;">"Processing: {}"</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>format<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN>map<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">)</SPAN> <SPAN class="" style="color: slategray; border: 0px; font-weight: inherit; font-size: 14px;"># keep track of what's happening</SPAN>
mxd <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit; font-size: 14px;">=</SPAN> arcpy<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>mapping<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>MapDocument<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN>map<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">)</SPAN>
<SPAN class="" style="color: slategray; border: 0px; font-weight: inherit; font-size: 14px;">#set relative paths property</SPAN>
mxd<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>relativePaths <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit; font-size: 14px;">=</SPAN> <SPAN class="" style="color: #990000; border: 0px; font-weight: inherit; font-size: 14px;">True</SPAN>
<SPAN class="" style="color: slategray; border: 0px; font-weight: inherit; font-size: 14px;">#save map document change</SPAN>
mxd<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">.</SPAN>save<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">(</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">)</SPAN>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.