Skip to content

Instantly share code, notes, and snippets.

@cindygis
Created May 29, 2015 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cindygis/af9911aa0ab2433117f7 to your computer and use it in GitHub Desktop.
Save cindygis/af9911aa0ab2433117f7 to your computer and use it in GitHub Desktop.
Updates a layer name with the name of the group layer it is in.
#
# @date 29/05/2015
# @author Cindy Williams
#
# Updates a layer name with the name of the group layer
# it is in, in an existing mxd.
#
# For use in the Python window in ArcMap.
#
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
lyrs = [lyr for lyr in arcpy.mapping.ListLayers(mxd) if lyr.isFeatureLayer]
for lyr in lyrs:
lyr.name = lyr.name + "_" + lyr.longName.split("\\")[0]
arcpy.RefreshTOC()
mxd.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment