So, I have about 50 mxd's with all broken layers that I have been going through and manually resetting. The data was moved from another computer and the folder structure was changed so it isn't just a simple process of changing (example):
"F:\Data\Rivers.shp" to "C:\Data\Rivers.shp"
it is more like :
"F:\Data\Rivers.shp" to C:\Data\Park\Water\Rivers.shp
and so on for all kinds of data (boundaries, veg cover, roads, etc.) each in their own sub-folder.
I wanted to make a script that I could run repeatedly whenever I opened one of these mxd's that would at least repair some of the more common layers that are found in most of my mxd's, and then I could manually repair the rest. That way I at least save myself some time.
I have been using something along the lines of :
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") for lyr in arcpy.mapping.ListLayers(mxd): if lyr == "Rivers": #Should this be the layner name in TOC or FC name? lyr.replaceDataSource(r"C:\Data\Park\Water", "SHAPEFILE_WORKSPACE", "Rivers")
The idea then would be to somehow add multiple "replace" scripts in the above for other common layers that are in my mxd's. However the above script doesn't even fix the Rivers layer. How can I get it to work, and also add in other layers to be repaired that have different file paths?
Sorry, I am a total novice at this stuff and I am probably going about it all wrong.