Good morning! I am trying to create a re-pathing script in python but am running into a few kinks. I am hoping that someone can offer some assistance 🙂What I have right now is ... import arcpy
mxd = arcpy.mapping.MapDocument("C:\TEMP\TEST.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.dataSource == "Database Connections\\SDEConnection.sde\PTD.AIRPORTS":
lyr.replaceDataSource("Database Connections\\SDEConnection.sde\PTD.ap", "SDE_WORKSPACE", "Airports")
mxd.saveACopy(r"C:\TEMP\NEWTEMP.mxd")
I've tried multiple versions in here with varying levels of success. Some don't change anything and just save a new MXD with a broken link. This one is actually changing the path but it's changing it to C:\Users\NAME\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\SDEConnection.sde\PTD.apClose .. but I'm trying to connect to our ArcGIS Server instance and NOT a local copy on my machine.Ultimately I am wanting the script to run through a list of layers so it can update multiple ones within the same MXD, all who will have new feature class names, which is why I am using the if lyr.dataSource = section... Does anyone know what I'm missing? I've been reading through the online documentation but it is very vague when it comes to replaceDataSource ..Thank you!