I had a similar problem to yours when my work upgraded its computer and changed around the network. In my instance it resulted in hundreds of maps with broken data links.
I wrote a script that, for all intensive purposes, should work, but fails whenever it reaches the lyr.replaceDataSource, and ultimately crashes when a datasource is a personal geodatabase.
However, it is a start for you, especially around line 32 - newDataSource = brokenDataSource.replace(r'N:', r'c:\users\athom\Documents\GIS\GIS_computer_06_20_2013\GIS_LOCAL_MASTER')
Hopefully you can use this as a start.
import arcpy, os, sys, traceback
workspace = r'c:\users\athom\Documents\GIS\GIS_computer_06_20_2013\GIS_LOCAL_MASTER\MAPS\Map_Projects\TEST'
arcpy.env.workspace = workspace
mxdList = arcpy.ListFiles("*.mxd")
for Map in mxdList:
filePath = os.path.join(workspace, Map)
mxd = arcpy.mapping.MapDocument(filePath)
brkLayerList = arcpy.mapping.ListBrokenDataSources(mxd)
for lyr in brkLayerList:
if lyr.supports("DATASOURCE") and lyr.supports("WORKSPACEPATH"):
brokenDataSource = lyr.dataSource
print brokenDataSource
if brokenDataSource.startswith('N'):
if brokenDataSource == brokenDataSource:
newDataSource = brokenDataSource.replace(r'N:', r'c:\users\athom\Documents\GIS\GIS_computer_06_20_2013\GIS_LOCAL_MASTER')
layerName = lyr.datasetName
ChangedDataSet = newDataSource.replace(layerName, '')
print 'newDataSource = ' + newDataSource
print 'ChangedDataSet = ' + ChangedDataSet
print 'layerName = ' + layerName
try:
if "shp" in newDataSource:
ChangedDataSet =ChangedDataSet.replace(' ','')[:-5]
print ChangedDataSet
layerName = layerName+'.shp'
print layerName
lyr.replaceDataSource(ChangedDataSet, "SHAPEFILE_WORKSPACE", layerName, True)
lyr.save()
elif "mdb" in newDataSource:
accessName = 'mdb'
ChangedDataSet = ChangedDataSet.split(accessName,1)[0]
ChangedDataSet = ChangedDataSet + 'mdb'
print 'ChangedDataSet = ' + ChangedDataSet
#lyr.replaceDataSource(ChangedDataSet, "ACCESS_WORKSPACE", layerName, True)
lyr.save()
elif "gdb" in newDataSource:
lyr.replaceDataSource(ChangedDataSet, "FILEGDB_WORKSPACE", layerName, True)
else:
lyr.replaceDataSource(ChangedDataSet, "RASTER_WORKSPACE", layerName, True)
except Exception as e:
print arcpy.AddError(e)
print "N FAILED"
elif brokenDataSource.startswith ('n'):
newDataSource = brokenDataSource.replace(r'n:', r'c:\users\athom\Documents\GIS\GIS_computer_06_20_2013\GIS_LOCAL_MASTER')
layerName = lyr.datasetName
ChangedDataSet = newDataSource.replace(layerName, '')
print newDataSource
print ChangedDataSet
print layerName
try:
if "shp" in newDataSource:
ChangedDataSet =ChangedDataSet.replace(' ','')[:-5]
print ChangedDataSet
layerName = layerName+'.shp'
print layerName
lyr.replaceDataSource(ChangedDataSet, "SHAPEFILE_WORKSPACE", layerName, True)
elif "mdb" in newDataSource:
lyr.replaceDataSource(ChangedDataSet, "ACCESS_WORKSPACE", layerName, True)
elif "gdb" in newDataSource:
lyr.replaceDataSource(ChangedDataSet, "FILEGDB_WORKSPACE", layerName, True)
else:
lyr.replaceDataSource(ChangedDataSet, "RASTER_WORKSPACE", layerName, True)
except arcpy.ExecuteError:
arcpy.AddError(GetMessages(2))
print "n FAILED"
else:
print 'Data Source Lost'
mxd.save()
#mxd.save()
del mxd