QuickTip: Copy Script Labels to Item Names [CS5]
As you probably know, in CS5, it’s really pain to work with Script Label‘s, and there is no easy way to address objects by Script Label. In pre-CS5 versions of InDesign, with item() we’ve received element Script Label but in CS5 we receive element name from Layer‘s panel. Using script versioning we can achieve pre-CS5 behavior, but it’s not really safe. So, why not copy all existing Script Label‘s into Layer‘s panel element names?
Keep in mind that setting element name in Layer‘s panel is done through .name() and for Script Label through .label(). So, don’t forget to adopt your scripts. Also, maybe it’s good to check if element name already exists, and if doesn’t then do the copy thing.
So, here is THE “SCRIPT”
var myDocItems = app.activeDocument.allPageItems;
for(var i = 0; i < myDocItems.length; i++)
if(!myDocItems[i].name)
myDocItems[i].name = myDocItems[i].label;
For more info about changes in CS5 read With CS5, some things have changed on Adobe’s InDesign Scripting forum.
That’s it!
Have fun!
IndiSnip on Twitter!
IndiSnip on Facebook!
Contact IndiSnip by e-mail!

Nice workaround!
Do you agree, that InDesign CS5/5.5 (I am using CS5.5) is working with scriptPreferences.version=”6.0″ as a standard?
In that case it is a must to write
app.scriptPreferences.version=”7.5″ or “7.0″
in your script.
What ist your experience with that?
Thanks so much for pointing this out! It took a long time for me to figure out that CS5 handled Script Labels differently…I was wondering why code samples I found weren’t working for me!
I appreciate that this blog exists. Thank you.