Home > InDesign Scripts > QuickTip: Copy Script Labels to Item Names [CS5]

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? :D

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” :D

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! :D

About these ads
Categories: InDesign Scripts Tags:
  1. j-per
    September 26, 2011 at 13:12 | #1

    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?

  2. May 25, 2012 at 16:09 | #2

    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.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 34 other followers

%d bloggers like this: