jeffpickles

Need Help Changing Paths to SDE

Discussion created by jeffpickles on Apr 8, 2011
Latest reply on Apr 11, 2011 by tlsilveus
This script works great when dealing with SHPs and GDBs, but crashes Python when I try to run it for SDE data. What am I doing incorrectly?

import arcpy, os
## Input folder containing MXDs you want to change here.
## This should be the root folder.
start = "X:\ArcGIS"

## The os.walk command tells the script to go through
## all subdirectories in the 'start' folder.
for root, dirs, files in os.walk(start):
    for file in files:
        ## This command looks for MXD files and ignores all others.
        if file.endswith(".mxd"):            
            path = os.path.abspath(os.path.join(root, file))
            mxd = arcpy.mapping.MapDocument(path)
            ## The string you want to find, the new string you want to replace it with.
            mxd.findAndReplaceWorkspacePaths(r"X:\ArcGIS\OLD.gdb\Old_Units", r"Database Connections\server.sde\SDE.DBO.New_Units")
            mxd.save()
del mxd


Everything works fine until I put the SDE connection in.

Outcomes