Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a MXD with some layers that have parentheses in them. I'd like to rename them via script.

Is this a valid approach?

import re
map = arcpy.mapping.MapDocument("CURRENT")
layers = arcpy.mapping.ListLayers(map)
for layer in layers:
        newName = re.sub("[()]", "",
        arcpy.Rename_management(layer, newName)

Rename_management is giving me an error:

Runtime error : ERROR 000840: The value is not a Data Element.

share|improve this question
up vote 12 down vote accepted

This is because arcpy.Rename_management does not work on a map layer object - it works on objects on the disk.

Instead try: = newName is a read/write attribute of the arcpy.mapping.Layer class.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.