Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Fixing broken links on multiple mxds

$
0
0
I looked thru the esri sample code and determined that the "replaceDatasource" function may fix broken links. However, I need to modify the script to fix broken links in many mxds. I hoping someone can spot the problem in this script:

Code:

import arcpy, os, glob
mxds_path = r'S:\\Users Shared\\LOpperman\\Town Scale MXDs\\MXDs\\targetlayers\\'
layer_name = r'dams'
data_frame = r'Primary'

for infile in glob.glob(os.path.join( mxds_path, "*.mxd" )):   
    mxd = arcpy.mapping.MapDocument(infile)
          for df in arcpy.mapping.ListDataFrames(mxd, data_frame):
            for lyr in arcpy.mapping.ListLayers(mxd, "", df):
              lyr.replaceDataSource("dams")

    mxd.save()


Viewing all articles
Browse latest Browse all 2485

Trending Articles