AnsweredAssumed Answered

Using arcpy.mapping to change the datasource for .mxd?

Question asked by Daryl.Hochhalter on May 31, 2018
Latest reply on May 31, 2018 by Daryl.Hochhalter

I have successfully changed the data sources for the map documents (.mxd) files, but find that when I open the mxd it puts a lock on both the old and new file GDB. I can't find anything in the updated mxd that references the old file GDB but there must be something left.

 

import arcpy
CurFldr = r'\\Gis Server Data\Replicas\test' + '\\'
OldGDB = arcpy.GetParameterAsText(0)
NewGDB = arcpy.GetParameterAsText(1)
mxd = arcpy.mapping.MapDocument(r'\\Gis Server Data\Replicas\test\test.mxd')
mxd.findAndReplaceWorkspacePaths(CurFldr + OldGDB, CurFldr + NewGDB)
mxd.saveACopy(r'\\Gis Server Data\Replicas\test\Copy_of_test.mxd')
del mxd

 

I have also tried mxd.replaceWorkspaces & mxd.save()

Using the buildt-in set datasource tool seems to work fine on the same mxd files.

Any ideas would be appreciated.

 

Outcomes