Using this https://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/updatingandfixingdatasources.htm as a guide I am trying to find and replace the datasources in my mxd to enterprise gis sources but the new mxd created just has the same datasources. I tried doing a find and replace to another filegeodatabase but it still isn't doing the replace.
... mxd = arcpy.mapping.MapDocument(r'Z:\GIS\scratch\Workspaces_SDE\GDB.mxd')
... mxd.findAndReplaceWorkspacePaths(r'K:\Water and Sewer\Services\Services.gdb', r'Z:\GIS\scratch\20210809.gdb')
... del mxd
Is the issue the spaces?
Yeah, I didn't copy the code over probably so you might have missed it but the save copy function is there and it does save a copy but none of the datasources are altered.
I tested the following and it worked for me.
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Temp\MxdDataSourceTest.mxd") mxd.findAndReplaceWorkspacePaths(r"C:\Temp\BPs.gdb",r"C:\Temp\BPs_1.gdb") mxd.saveACopy(r"C:\Temp\MxdDataSourceTest2.mxd") print 'done'
That is pretty much what I am doing without the print "done" at the bottom. Not sure what is happening it runs as if it worked with no errors but the datasources are unchanged. I even tried to replace something simple like "K" to "LOL" and it still didn't work (I choose LOL so it would stand out). I even put it in a try statement with an error capture and nothing.