I have inherited a number of ArcMap projects, where the data sources have been broken by various people's file admin. Shapefiles have been moved from one folder to another, but subdirectory organisation remains the same. I am trying to fix the links using updateConnectionProperties. I use the following code on individual shapefiles, but cannot get the desired result.
variable "newsource" returns a correct filepath (printed by line 7) but I think line 8 is the problem as "not possible" is printed. No errors are returned. Any help appreciated. Thanks
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Users\CAddison\Documents\ArcGIS\Test001.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
try:
oldsource = lyr.dataSource
newsource = oldsource[0:53]+str("\\NEW\\")+oldsource[65:]
print newsource
lyr.updateConnectionProperties(oldsource, newsource)
except:
print "not possible"