What version of ArcGIS are you using. I have been able to replace rasters (see my addin Python addin for data inventory and “broken-link” repair. for my full .py files) . This could be modified to update non-broken links (I haven't done that yet)
Just a snippet for the raster (from repair broken link tool in my addin) ...it won't do much by itself, but might give you an idea. To see it in context, check out the addin.
NOTE: indentation of the first else removed for paste in geonet
else: #if lyr.supports("DATASOURCE") and lyr.supports("DATASETNAME"):
updateStatus = str(updatePath[0]) # used for message only
if lyr in theTables:
#myMsgs(" thinks its a table....using findAndReplsWorkspacePath")
myMsgs(" *Moving {0}: {1} to new: {2}".format(updatePath[3], lyr.dataSource, updatePath[0]))
reportFile.write("\n Moving {0}: {1} to new: {2} \n".format(updatePath[3], lyr.dataSource, updatePath[0]))
lyr.findAndReplaceWorkspacePath(lyr.dataSource, updatePath, False)
elif lyr.isRasterLayer:
#myMsgs(" thinks its a raster....using findAndReplsWorkspacePath")
myMsgs(" *Moving {0}: {1} to new: {2}".format(updatePath[3], lyr.dataSource, updatePath[0]))
reportFile.write("\n Moving {0}: {1} to new: {2} \n".format(updatePath[3], lyr.dataSource, updatePath[0]))
newType = "RASTER_WORKSPACE"
for extType in lstExtDatatype:
if extType[0] in updatePath[0]:
newType = extType[1]
if extType[0] == '.gdb':
newDSPath = newDSPath.split('.gdb', 1)[0] + '.gdb'
#newType = extType[1]
elif extType[0] == '.sde':
newDSPath = newDSPath.split('.sde', 1)[0] + '.sde'
break
lyr.replaceDataSource(newDSPath, newType, newDSName, False)
if not sameType:
testOldTOC = updatePath[4].strip('\\')
if lyr.name == testOldTOC:
lyr.name = lyr.datasetName
else:
newType = updatePath[1]
btw -- you can replace all "myMsgs" with "print"