Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

  1. I'm updating to 9.3 to 10.1 - I need to replace my shapefile data source to my ArcSDE files.
  2. I have over 4000 mxds with several shapefiles with the data source pointing to: R:\Shapefiles[layer folders*.shp
  3. 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]

  4. 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
share|improve this question

marked as duplicate by blah238, Aaron, Aragon, iant, R.K. Feb 5 '13 at 3:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

When you say 'ESRI Replacing data source help' are you referring to arcpy.mapping scripting environment? – danagerous Jan 29 '13 at 17:03
"none have worked" AKA "does not work" is not useful when asking a question. What is useful is explaining what you tried and what errors you received. – Luke Jan 31 '13 at 4:26

I think danagerous mentioned the right tool for the job. In the 10.1 doc, there is even a couple of examples for migrating data. What are the errors you encountered when you attempted to use python? Data is migrated from one workspace type to another workspace type

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.