The problem may be that your not specifying the data frame. Try the following below. It will replace all feature classes within an MXD with its corresponding feature class in the other file geodatabase.import arcpy, os, glob
from arcpy import mapping
folderPath = r"Z:\ESRI\Templates\IOR_2010\TemplateFiles\TemplateFiles.gdb\SOILS"
env.overwriteOutput = True
for filename in glob.glob(os.path.join(folderPath, "*.mxd")):
fullpath = os.path.join(folderPath, filename)
mxd = mapping.MapDocument(filename)
for df in mapping.ListDataFrames(mxd, "*"):
for lyr in mapping.ListLayers(mxd, "*", df):
print lyr.name
new_name = lyr.name + "_IF"
try:
lyr.replaceDataSource(r"Z:\Site\Sitename\D01_IF.gdb\SOILS_IF", "FILEGDB_WORKSPACE", new_name)
except ValueError:
pass
print "Successfully updated layer"
mxd.saveACopy(r"Z:\ESRI\Figure_Sourcing\Figures\TestFigs\IOR\MapSourcingTest\Test2.mxd")
del mxd