This is what I was trying the last time I worked on it, but this did not work.When you mention using If Then are you thinking that it should be before or after the replace data? I was working on the hopes that if it mis-assigned it to BULLITT.cn in the replacedatasource I could change it afterwards, which did not work. I figured it was a long shot but worth trying! import arcpy, os
from arcpy import env
from arcpy import mapping
env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("C:\TEMP\TEST.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.datasetName == "PTD.CONTOURS_JEFF":
lyr.replaceDataSource("Database Connections\\GIS_LOJIC.sde", "SDE_WORKSPACE", "PTD.cn")
if "BULLITT" in lyr.name:
lyr.name = "PTD" + lyr.name.split(".")[2]
mxd.saveACopy(r"C:\TEMP\NEWTEST.mxd")