try:
import arcpy.mapping, os, sys, string, traceback
mxd = arcpy.mapping.MapDocument("CURRENT")
for dataframe in arcpy.mapping.ListDataFrames(mxd):
BrokenLinkList = arcpy.mapping.ListBrokenDataSources(dataframe)
for item in BrokenLinkList:
print item.datasetName
if item.datasetName == r"LummiReservationFullBoundary":
print "droppin' in"
#The path to the new directory...
newWorkspace = r"Z:\Data\Boundaries\Administrative\Lummi.gdb\TribalBoundaries"
#The new dataset name...
datasetName = r"LummiReservation"
#This should have a "FEATUREDATASET" options to replace FILEGDB_WORKSPACE.
item.replaceDataSource (newWorkspace, "FILEGDB_WORKSPACE", datasetName, False)
arcpy.RefreshTOC()
#mxd.save()
del mxd
print "Done"
except arcpy.ExecuteError:
msgs = arcpy.GetMessages(2)
arcpy.AddError(msgs)
print msgs
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
print pymsg + "\n"
print msgs
Solved! Go to Solution.