Possible Duplicate:
Permanently replace/update SDE server + service in each SDE Layer in an MXD
First let me say I have probably read every link regarding changing DATA Sources on the internet from the ARCGIS 10 tool to Python, however none have worked for me. What i'm trying to do is very simple in concept.
Please don't recommend the ESRI Replacing data source help.
- I'm updating to 9.3 to 10.1 - I need to replace my shapefile data source to my ArcSDE files.
- I have over 4000 mxds with several shapefiles with the data source pointing to: R:\Shapefiles[layer folders*.shp
I need to change the shapefile datasource to point to C:\Users\lmuhammad\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\Connection to PGCGIS02.sde[gisdev.layername][gisdev.filename]
I need to repeat for over 4000 mxds automatically.
easy right.. HELP!!!!
------ UPDATE
This works ok xcept if the shapefile name differs greatly from SDE featureclass, =no connection any fixes?
import arcpy, glob
newSdePath = r"Database Connections\Connection to sdename.sde"
for file in glob.glob(arcpy.GetParameterAsText(0) + r"C:\*.mxd"):
mxd = arcpy.mapping.MapDocument(file)
for df in arcpy.mapping.ListDataFrames(mxd):
for lyr in arcpy.mapping.ListLayers(mxd, ""):
if lyr.isFeatureLayer== True:
lyr.replaceDataSource(newSdePath, "SDE_WORKSPACE","", False)
mxd.save()del mxd