AnsweredAssumed Answered

Reset the paths script

Question asked by sdkovach_usfs on Jul 16, 2019
Latest reply on Jul 16, 2019 by Dan_Patterson

I'm trying to get a script to reset the paths of data sources from an archive path to a current path. However, the script is only changing one of the paths and not all of the paths. Here is my code:

import arcpy, os
arcpy.AddMessage("\n\n" + "Re-source MXDs was developed by Carl Beyerhelm, modified by Steve Kovach" + "\n")
mxdFolder = arcpy.GetParameterAsText(0)  ## The project MXD folder
oldFolder    = arcpy.GetParameterAsText(1)  ## The archived data folder path
newFolder    = arcpy.GetParameterAsText(2)  ## The current data folder path
arcpy.env.workspace = mxdFolder
mxdList = arcpy.ListFiles("*.mxd")  ## Get a list of the MXDs
for mxd in mxdList:  ## For each MXD
    arcpy.AddMessage("\n" + "Re-sourcing " + mxd + "...")
    mapDoc = arcpy.mapping.MapDocument(os.path.join(mxdFolder, mxd))  ## Get the mapDoc object
    mapDoc.findAndReplaceWorkspacePaths(r"oldFolder", r"newFolder", True)  ## Replace the obsolete path with the new path
    mapDoc.save()  ## Save the updated MXD
    del mapDoc  ## Release the mapDoc object
arcpy.AddMessage("\n\n" + "OK, done!" + "\n\n")

 

Any ideas where I'm going wrong?

Outcomes