Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

INDD script for renaming within layers.

Community Beginner ,
Feb 17, 2018 Feb 17, 2018

Hello,

I would like to ask if someone know script that allows to rename "<polygon>, <line>" (as on screen below) etc. inside layer to wanted name?

I have a lot of names that needs to be changed, and changing it manually is a bit of a pain.

I know script that can change layer name, but it does not work on the "sub layers" (I know INDD does not have sub layers, but I just want to make clear what I'm talking about),

Please help!

1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 17, 2018 Feb 17, 2018

The items listed in a layer's drop down are the active page's page items and a page item can be named via scripting. This example names all of the active page's items with the item's id followed by "My Name".

var n="My Name"

var p=app.activeWindow.activePage.allPageItems; 

for (var i = 0; i < p.length; i++){

    p.name=p.id + "-" + n;

};

Screen Shot 2.png

Or it could be the selected items

var n="New Name"

//var p=app.activeWindow.activePage.allPageItems; 

var p=app.activeDocument.selection;

for (var i = 0; i < p.length;

...
Translate
Enthusiast ,
Feb 17, 2018 Feb 17, 2018

Hi,

are these layer elements polygons, that you created in InDesign?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2018 Feb 17, 2018

The items listed in a layer's drop down are the active page's page items and a page item can be named via scripting. This example names all of the active page's items with the item's id followed by "My Name".

var n="My Name"

var p=app.activeWindow.activePage.allPageItems; 

for (var i = 0; i < p.length; i++){

    p.name=p.id + "-" + n;

};

Screen Shot 2.png

Or it could be the selected items

var n="New Name"

//var p=app.activeWindow.activePage.allPageItems; 

var p=app.activeDocument.selection;

for (var i = 0; i < p.length; i++){

    p.name=p.id + "-" + n;

};

Screen Shot 3.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 17, 2018 Feb 17, 2018

Hello,

You  are my star rob day.

I have changed one string only:

var n="mynana"

//var p=app.activeWindow.activePage.allPageItems;  

var p=app.activeDocument.selection;

for (var i = 0; i < p.length; i++){

    p.name= n;                                             over here, so I get only word that I need inserted on marked layer.

};

Thanks!!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 17, 2018 Feb 17, 2018
LATEST

If you need a dialog for the name try this:

var d = app.dialogs.add({name:"Item Names"});

var tf = d.dialogColumns.add().textEditboxes.add({editContents:"", minWidth:180});

d.show();

var n = tf.editContents;  

d.destroy();

var p=app.activeDocument.selection;

for (var i = 0; i < p.length; i++){

    p.name=n;

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines