I have read up on the ESRI technical article here.
Basically I had a corrupt feature class that I rebuilt from a backup and renamed. As I created more .mxd's with this renamed feature class, all .mxd's previous to the corruption now have broken sources. I found a code snippet on the article for replacing a data source. The problem is, I want to run this code on many .mxd's in a folder but this code only runs on single .mxd's. I have little python experience so I need some help here.
Side Note: I am delivering these .mxd files along with the FGDB to a client. I am batch running a script to enable relative links on all .mxd files. Will this affect the code I need to run on fixing data sources?
In this code, MajorRoads is being renamed to Highways.
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd") for lyr in arcpy.mapping.ListBrokenDataSources(mxd): if lyr.supports("DATASOURCE"): if lyr.dataSource == r"C:\Project\Data\Transportation.gdb\MajorRoads": lyr.replaceDataSource(r"C:\Project\Data\Transportation.gdb", "FILEGDB_WORKSPACE", "Highways") lyr.name = "Highways" mxd.saveACopy(r"C:\Project\Project2.mxd") del mxd