1

I like to make Layer Packages for our group as this keeps things consistent. One holdup in making my packages is the requirement for all layers to have a layer description in the General Layer Properties section. Is there a batch process where I could put a blanket "description" in just to speed things up? Better yet, is there a script I could use to make "Description" the same as "Layer Name" as a batch process.
I have 297 .asc raster that I would ideally like to have the descriptions match the layer name. However even just adding a generic description like "asc raster" would at least let me make my layer package without having to click on each individual layer and copy and pasting the layer name into description.

3

I don't know what kind of experience you have with Python, but you can read and write a layer's description via the description property of the layer class. The following code snippet iterates through all of the layers in your table of contents, and replaces any blank descriptions with the layer's name:

import arcpy, os

#Get map document object
CurrentMXD = arcpy.mapping.MapDocument("CURRENT")

#Iterate through layers
for Layer in arcpy.mapping.ListLayers(CurrentMXD):
    if len(Layer.description) == 0:
        Layer.description = Layer.name

This works for layers and layer groups. Things can get messy with certain specialized layers (e.g. network analyst layers), but it should be fairly robust.

If you've never run Python code before, open the Python window from the Geoprocessing menu, paste this into the console with [CTRL] + [V], and press [ENTER].

  • You are a genius! This was awesome. Thank you a million. Sorry to reply and thank you so late. I was out of country and hadn't checked back. – Leibniz Feb 24 '15 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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