Can the layer name in the TOC be updated using arcpy?

08-19-2015 10:02 AM
MVP Esteemed Contributor

I'm working on a script to update all my broken links in my mxd's do to server and folder changes.  Some of these changes are from one data type to another. I'm working my way thru the various combinations, and now working on an old SDE to FGDB.  Unfortunately the name in my Table of Contents is still called the default SDE connection name (e.g. SDE_COMMON.SDEWILD.NED_HILLSHADECLIP).  I would like to rename this in the TOC to just NED_HILLSHAPECLIP in this case.

In short, I need to replace my   ""  with   "lyr.datasetName"

Is there a way to do this in python?

I am trying to keep my script/tools 10.2.2 compatible.


0 Kudos
2 Replies
MVP Esteemed Contributor

ok...may have been overthinking this.  I think all I needed to do is = lyr.datasetName

when testing in the .mxd, I need to refresh the mxd/TOC.  This will be run in ArcCatalog and will test my script and update soon.

Sometimes writing out the question is enough to make the obvious pop out.  ugh!

Frequent Contributor

It happens to everyone.