Updating and fixing data sources with arcpy mapping

To change the data layer source name use the 'replace Data Source' method instead.During a recent customer upgrade from ESRI 9.3 to 10SP3, we uncovered a last minute "gotcha" regarding over 1,000 map files floating around several share drives.The code I have written so far loop through the map documents in a directory, find which layers have a broken data source and determine if it is a shapefile, personal geodatabase feature class, file geodatabase feature class or a raster.

Attach the following python code to a script in the toolbox of the mxd you wish to update.

This will allow you to update the directory the data layer is referencing, but will NOT allow you to change the data layer source name itself.

Since the new production environment was now using a brand new Sql Server installation, with a different server name, all of the data sources that were attached to the map files would now be invalid.

We identified three scenarios to handle this situation: First, whenever a user opens the map, they can manually repoint the data source.

Map Document(r"Path\To\MXD") for df in arcpy.mapping. Furthermore, when I remove the raster dataset from the mxd and rerun the same script it works fine.

Error Message: This is the traceback I get from running it with the raster dataset in the MXD: import arcpy File "C:\Program Files (x86)\Arc GIS\Desktop10.2\arcpy\arcpy\utils.py", line 181, in fn_ return fn(*args, **kw) File "C:\Program Files (x86)\Arc GIS\Desktop10.2\arcpy\arcpy\_mapping.py", line 695, in find And Replace Workspace Path return convert Arc Object To Python Object(self._arc_And Replace Workspace Path(*gp_fixargs((find_workspace_path, replace_workspace_path, validate), True))) Value Error: Layer: Unexpected error Question: I was under the impression (Arc Py documentation) that raster datasets worked fine with the And Replace Worksapce Path method, yet I am still having these issues. Do I need to phrase my arguments differently, or do I need to use a different method to replace a raster path?

Note: this dialog is intended primarily for preparing map documents for publication.

Customizations (VBA code, UI Controls and custom toolbars), graphs, and table window appearance properties are removed from files when you update their data sources using this dialog.

This seems reasonable at first, but requires the user to perform an additional task which they weren’t expecting to do.

The second scenario is similar to the first, but to hire a temporary worker to open all the maps and fix the data source.

Environment: as opposed to the one for the individual layers.