Select to view content in your preferred language

Changing MXD to store relative pathnames to data sources via ArcPy

972
3
06-07-2011 08:10 AM
RobertoFigueroa
Occasional Contributor
Just wondering if there is way via ArcPy to change an MXD to store relative pathnames to data sources. I would like to run  a Python script that loops through multiple MXDs in a given folder and changes them to relatives pathnames.
Thanks
Roberto
Tags (2)
0 Kudos
3 Replies
JasonScheirer
Esri Alum
Not in 10.0. The MapDocument class has a relativePaths attribute, but it is read-only.
0 Kudos
ZackBartlett
Regular Contributor
Might we be able to write to this property in future releases of ArcGIS? I've heard the ArcPy Site Package may be expanded in 10.1+.
0 Kudos
PeterMacKenzie1
Emerging Contributor
if this helps.
10.1 SP1

import arcpy, os

#workspace to search for MXDs
Workspace = r"C:\Geo"
arcpy.env.workspace = Workspace

#list map documents in folder
mxdList = arcpy.ListFiles("*.mxd")

#set relative path setting for each MXD in list.
for file in mxdList:
    #set map document to change
    filePath = os.path.join(Workspace, file)
    mxd = arcpy.mapping.MapDocument(filePath)
    #set relative paths property
    mxd.relativePaths = True
    #save map doucment change
    mxd.save()
0 Kudos