4

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.save()del mxd
2
  • 1
    When you say 'ESRI Replacing data source help' are you referring to arcpy.mapping scripting environment?
    – danagerous
    Commented Jan 29, 2013 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.
    – user2856
    Commented Jan 31, 2013 at 4:26

1 Answer 1

3

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?

http://resources.arcgis.com/en/help/main/10.1/index.html#//00s30000004p000000 Data is migrated from one workspace type to another workspace type

0

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