Yeah, I agree.For ArcGIS 10 - arcpy.mappingAn example (change multiple layer sources in a single .mxd document:
01 import arcpy
02 # Define the path to the .mxd map document you want to update
03 mxd = arcpy.mapping.MapDocument(r"C:\Temp\Esri_sde_service.mxd")
04
05 # Define which connection strings will be changed. Here there is just one connection string being changed.
06 mxd.findAndReplaceWorkspacePaths(r"C:\Users\username\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Production@sde.sde",
07 r"C:\Users\username\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Development@sde.sde")
08
09 # It is possible to add more connection strings that have to be changed in the same map document
10 mxd.findAndReplaceWorkspacePaths(r"C:\Users\username\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\RasterData.sde",
11 r"C:\Users\username\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\RasterData_load.sde")
12
13 # The path where the new .mxd map document will be saved to.
14 mxd.saveACopy(r"C:\GIS\Output\Sde_load.mxd")
15 del mxd
Another example (multiple SDE data sources in multiple.mxd map documents):
import arcpy, os
02 # Define the path to the folder where multiple .mxd map documents are stored
03 folderPath = r"C:\GIS\Maps"
04 for filename in os.listdir(folderPath):
05 fullpath = os.path.join(folderPath, filename)
06 if os.path.isfile(fullpath):
07 basename, extension = os.path.splitext(fullpath)
08 if extension.lower() == ".mxd":
09 mxd = arcpy.mapping.MapDocument(fullpath)
10
11 # Define which connection strings will be changed. Here there are two connection strings being changed. One for vector data
12 mxd.findAndReplaceWorkspacePaths(r"C:\Users\username\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Production@sde.sde", r"C:\Users\username\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\Development@sde.sde")
13
14 # and second one for raster data which may have used another connection string.
15 mxd.findAndReplaceWorkspacePaths(r"C:\Documents and Settings\username\Application Data\ESRI\ArcCatalog\raster_data.sde", r"C:\Documents and Settings\username\Application Data\ESRI\Desktop10.0\ArcCatalog\raster_dataV10.sde")
16
17 # You can use even more defitions of the connection strings that will be changed. Note that here is the update of the path from 9.3 to 10 is going on which you can see since the path to the .sde file is different (update from 9.3 to 10)
18 mxd.findAndReplaceWorkspacePaths(r"C:\Documents and Settings\username\Application Data\ESRI\ArcCatalog\TopologyData.sde", r"C:\Documents and Settings\username\Application Data\ESRI\Desktop10.0\ArcCatalog\TopologyData_manager.sde")
19 mxd.save()
20 del mxd