import arcpy, os, sys # Folder location of maps that need updating. Setup for script tool. Can be changed to hardcoded path. folderpath = arcpy.GetParameterAsText(0) arcpy.env.workspace = r"\\x2x2x2x2.x2x2x2x2x2\???-ocd\Users\my.name\My Documents" for file in arcpy.ListFiles("*.mxd"): print file mxd = arcpy.mapping.MapDocument(os.path.join(folderpath,file)) mxd.findAndReplaceWorkspacePaths(r"\\xxxx.xxxx.xxx", r"\\x2x2x2x2.x2x2x2x2x2") mxd.save() del mxd sys.exit()import arcpy, os, sys # Folder location of maps that need updating. Setup for script tool. Can be changed to hardcoded path. folderpath = arcpy.GetParameterAsText(0) arcpy.env.workspace = "\\\\nmfs.local\\akc-ocd\\Users\\jan.benson\\My Documents\\" for file in arcpy.ListFiles("*.mxd"): print file mxd = arcpy.mapping.MapDocument(os.path.join(folderpath,file)) print file oldpath = "\\\\xxxx.xxxx.xxx\\???-ocd\\Users\\my.name\\My Documents\\" newpath = "\\\\x2x2x2x2.x2x2x2x2x2\\???-ocd\\Users\\my.name\\My Documents\\" mxd.findAndReplaceWorkspacePaths(oldpath, newpath) print file mxd.save() del mxd
Solved! Go to Solution.
import arcpy, os, sys folderpath = r"\\server\temp\python" arcpy.env.workspace = r"\\server\temp\python" for file in arcpy.ListFiles("*.mxd"): mxd = arcpy.mapping.MapDocument(os.path.join(folderpath,file)) oldpath = r"C:\Temp\Python\Test.gdb" newpath = r"\\server\Temp\Python\Test.gdb" mxd.findAndReplaceWorkspacePaths(oldpath, newpath) mxd.save() del mxdimport arcpy, os, sys folderpath = r"C:\temp\python" arcpy.env.workspace = r"\\server\temp\python" for file in arcpy.ListFiles("*.mxd"): mxd = arcpy.mapping.MapDocument(os.path.join(folderpath,file)) oldpath = r"C:\Temp\Python\Test.gdb" newpath = r"\\server\Temp\Python\Test.gdb" mxd.findAndReplaceWorkspacePaths(oldpath, newpath) mxd.save() del mxdimport arcpy, os, sys folderpath = r"\\server\temp\python" arcpy.env.workspace = r"\\server\temp\python" for file in arcpy.ListFiles("*.mxd"): mxd = arcpy.mapping.MapDocument(os.path.join(folderpath,file)) oldpath = r"C:\Temp\Python\Test.gdb" newpath = r"\\server\Temp\Python\Test.gdb" mxd.findAndReplaceWorkspacePaths(oldpath, newpath) mxd.save() del mxdimport arcpy, os, sys folderpath = r"C:\temp\python" arcpy.env.workspace = r"\\server\temp\python" for file in arcpy.ListFiles("*.mxd"): mxd = arcpy.mapping.MapDocument(os.path.join(folderpath,file)) oldpath = r"C:\Temp\Python\Test.gdb" newpath = r"\\server\Temp\Python\Test.gdb" mxd.findAndReplaceWorkspacePaths(oldpath, newpath) mxd.save() del mxdI am running into the same problem using findAndReplaceWorkspacePaths not being saved after calling mxd.save()
Except all of my paths are absolute paths. No UNC paths being used for map document or connection files.