Hello! The first script works; it finds all data sourced to the first path and changes it to the second path. The second script is my attempt to search for multiple paths, and change them all to a different path. The second script fails, and I can't figure out why. Thanks for looking!
SCRIPT #1 import arcpy, os folderPath = r"U:\ServerMigration" for filename in os.listdir(folderPath): fullpath = os.path.join(folderPath, filename) if os.path.isfile(fullpath): basename, extension = os.path.splitext(fullpath) if extension.lower() == ".mxd": mxd = arcpy.mapping.MapDocument(fullpath) mxd.findAndReplaceWorkspacePaths(r"F:\ServerMigrationTest\Geodatabases", r"U:\ServerMigration\Geodatabases") mxd.save() del mxd
SCRIPT #2 import arcpy, os folderPath = r"U:\ServerMigration" for filename in os.listdir(folderPath): fullpath = os.path.join(folderPath, filename) if os.path.isfile(fullpath): basename, extension = os.path.splitext(fullpath) if extension.lower() == ".mxd": mxd = arcpy.mapping.MapDocument(fullpath) mxd.findAndReplaceWorkspacePaths(r"\\datsrva\017GisData", r"F:\ServerMigrationTest\Geodatabases") mxd.findAndReplaceWorkspacePaths(r"\\Gissrv1\017gisdatt\017GISDATA", r"F:\ServerMigrationTest\Geodatabases") mxd.findAndReplaceWorkspacePaths(r"\\datsrv1\017GisData", r"F:\ServerMigrationTest\Geodatabases") mxd.findAndReplaceWorkspacePaths(r"Z:", r"F:\ServerMigrationTest\Geodatabases") mxd.findAndReplaceWorkspacePaths(r"\\gissrv1\017GisData", r"F:\ServerMigrationTest\Geodatabases")
Well, I'm not certain anyone could have figured this one out without seeing my entire file structure. The answer is: when describing the existing data source path, you must include the path all the way down to the last folder which contains the database. Now I am on a journey to write a script that will omit this restriction; if need be, I will generate another post specific to that need. Thank you!
Well, I'm not certain anyone could have figured this one out without seeing my entire file structure. The answer is: when describing the existing data source path, you must include the path all the way down to the last folder which contains the database. Now I am on a journey to write a script that will omit this restriction; if need be, I will generate another post specific to that need. Thank you!
There should be no such restriction with findAndReplaceWorkspacePaths. You could replace "C:\" with "D:\" and not have to specifiy the rest of the folder path. I'm curious what you discover as you dig into it a bit futher.