AnsweredAssumed Answered

Find and Replace Workspace Paths- single path works, but multiple paths fails

Question asked by MLF on Apr 13, 2012
Latest reply on Apr 16, 2012 by jbarrette-esristaff
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")

            mxd.save()
del mxd

Outcomes