I have recently renamed 20 feature layers that are currently saved in approximately 100 MXDs. To fix the broken data source as a result of changing the name, I am using the following code:
import arcpy
mxd = arcpy.mapping.MapDocument(r"//test.mxd") #file path for mxd
for lyr in arcpy.mapping.ListLayers(mxd)
if str(lyr.name)=="original":
lyr.replaceDataSource(r"//test.gdb", "FILEGDB_WORKSPACE", "new") #file path for geodatabase
print("Success")
mxd.save()
del mxd
However, this code means that I have to update one MXD at a time.
Is there a way I can add into this code that I would like it to check multiple MXDs for the same layers and replace with the same new data name?
.bak
copy of the previous document before saving over it.