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.