Select to view content in your preferred language

Repair Data Source - New Data Location

1994
6
02-07-2018 12:26 PM
by Anonymous User
Not applicable

I'm migrating my data to a new server and I have 1000's of MXD's which will have broken layers due to the new location of the data.

Is there a method of sourcing all these MXD's to the new data location from multiple machines using single-use licenses?

I've come across this thread a couple times with no clear answer form what I could see.

Thanks

0 Kudos
6 Replies
TinaMorgan1
Frequent Contributor

You can use python to script the resourcing of all your map documents.

Updating and fixing data sources with arcpy.mapping—Help | ArcGIS for Desktop 

A simple example would be...

import arcpy
 
mxd = arcpy.mapping.MapDocument(r"C:\ResourceMe.mxd")
 
for lyr in arcpy.mapping.ListLayers(mxd):
    if lyr.isRasterLayer:
        print lyr.dataSource
        wsp = lyr.workspacePath
        ds = lyr.datasetName
 
        lyr.replaceDataSource(r"C:\Users\userprofile\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DirectConnect.sde", "SDE_WORKSPACE", ds, False)
        lyr.name = ds
 
    else:
        mxd.findAndReplaceWorkspacePaths(r"C:\Users\userprofile\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\AppSvr10.sde",r"C:\Users\userprofile\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DirectConnect.sde", False)
               
       
mxd.saveACopy(r"C:\ResourceMe1.mxd")
del mxd
 
print complete
JayantaPoddar
MVP Esteemed Contributor

Just thought you could use Syntax Highlighter while writing a script here.



Think Location
TinaMorgan1
Frequent Contributor

That just made my life so much better, and it is Friday!

0 Kudos
by Anonymous User
Not applicable

I've downloaded your add-in and every step works great until step 5.

I get the following error message:

I'm currently running 10.6 and here is a snippet of my "UpdateToNewDrive.csv"

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

I haven't tested on 10.6, so that might be the issue.  But you can try to unzip the .addin and go directly to the toolbox.  Right-click on the tool and Source.  See if it can find the .py script for the tool.  You may need to go up a folder to find the scripts folder.

I know I have had some issues with 10.5.1 with the "store relative path" for the script doing some weird stuff (trying to look on the "C$" share) when upgrading to newer version.  It was developed mainly on 10.2.x.

The only other thing might be if you have spaces in the path names.  I can't remember if I handle things for that.