Being a recent graduate and just started working I'm fairly new with Python, but I'm trying my best to learn and I find it really fun and useful! However, I'm stuck with a problem I can't seem to solve on my own. We recently migrated our data from FGDB to an SDE database and I've got hundreds of lyr-files containing multiple layers which I need to change data sources for. The file names in the SDE, however, is not exactly the same as in the FGDB.
For example:
Name in FGDB: kl_c_Clip
Name in SDE: blabla.whatup.kl_c_y
As you can see part of the name is the same, which is pretty much always the case. I've been looking around for a solution but haven't found any where the names differ. I'm thinking the script should look something like this:
sdePath = r"Database Connections\Connection to thedatabase.sde"
mxd = arcpy.mapping.MapDocument("CURRENT")
for df in arcpy.mapping.ListDataFrames(mxd):
for lyr in arcpy.mapping.ListLayers(mxd, ""):
if lyr.isFeatureLayer == True:
lyr.replaceDataSource(sdePath, "SDE_WORKSPACE", "")
del mxd
I run the script and it's loading, but nothing happens. No error or anything, and no change in data sources. I realize I have to get the name change in there somewhere, I just don't know where and how.