Hello everyone,I am trying to replace the workspace path or datasource path in a number of mxd's. I am not sure which one is supposed to work for my scenario. The layers in my map that I want to change, all have the same workspace:Z:\ESRI\Templates\IOR_2010\TemplateFiles\TemplateFiles.gdbEach layer is sourced to a feature class within that directory.I want to resource to a new workspace:Z:\Site\Sitename\D01_IF.gdbThe names of the feature classes are different in each gdb, but they contain the same data and structure. (ie The "SOILS" feature class in the old gbd is now named "SOILS_IF" in the new gbd.So in other words, I want to change the datasource from:Z:\ESRI\Templates\IOR_2010\TemplateFiles\TemplateFiles.gdb\SOILSto:Z:\Site\Sitename\D01_IF.gdb\SOILS_IFI've been through the help menu for "Updating and fixing data sources" The scenario it gives for the lyr.replaceDataSource syntax, explains that you can change the source from a feature class that has been renamed in the same file gdb, but none of the scenarios offer a solution to resourcing to a new gdb with a feature class of a different name. I thought my code below would have done that, but it does not change the data source. It doesn't spit out an error message either. Can anyone suggest an issue with my code?Thanks,Mike
folderPath = r"Z:\ESRI\Figure_Sourcing\Figures\MapSourcingTest"
try:
for filename in glob.glob(os.path.join(folderPath, "*.mxd")):
fullpath = os.path.join(folderPath, filename)
#print "Editing", filename
mxd = arcpy.mapping.MapDocument(filename)
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == "Soil Map Unit":
print lyr.dataSource + " Datesource"
lyr.replaceDataSource(r"Z:\Site\Sitename\D01_IF.gdb", "FILEGDB_WORKSPACE", r"SOILS_IF")
mxd2.saveACopy(r"Z:\ESRI\Figure_Sourcing\Figures\TestFigs\IOR\MapSourcingTest\Test2.mxd")