Need Help Changing Paths to SDE

2220
10
04-08-2011 08:45 AM
JeffPickles
Deactivated User
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.
Tags (2)
0 Kudos
10 Replies
TerrySilveus
Frequent Contributor
Yeah, I just went with a quick and dirty
print path

after the save step. Works wells enough for me.


I almost suggested that
0 Kudos