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

How to change an objects name via script

Explorer ,
Feb 21, 2020 Feb 21, 2020

I am using inDesign 15.0.1.  I have an indd file with thousands of single pages.  On each page is a small PNG file which was placed into a frame using the Rectangle Frame Tool and Place.

 

When you look on the Layers tab, you see something similar to <myfile.png> for the object.  I know I can manually click on it and change its name to something more descriptive, but I don't want to have to do this manually.

 

How can I write a script to go through all of the pages, and change the name?  It will be the same name for all of the pages (even though the PNG file is different for every page).

TOPICS
How to , Scripting
1.1K
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

Engaged , Feb 21, 2020 Feb 21, 2020

Here is a small script, that renames all rectangles in the layer palette, if a .png file is placed.

var curDoc = app.activeDocument;
var curLinks = curDoc.links;
var NAME_IN_LAYER = "MyName";

for (var i=0; i<curLinks.length; i++) {
        
        var curLink = curLinks[i];
        var curLinkName = curLink.name;
        if ( curLinkName.indexOf (".png") != -1) {
            var curRectangle = curLink.parent.parent;
            curRectangle.name = NAME_IN_LAYER;
        }
    
}
Translate
Advocate ,
Feb 21, 2020 Feb 21, 2020

I have no idea how to do this or if it's even possible. My question is why do you want to do this? Seems like an odd request.

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
Engaged ,
Feb 21, 2020 Feb 21, 2020

Here is a small script, that renames all rectangles in the layer palette, if a .png file is placed.

var curDoc = app.activeDocument;
var curLinks = curDoc.links;
var NAME_IN_LAYER = "MyName";

for (var i=0; i<curLinks.length; i++) {
        
        var curLink = curLinks[i];
        var curLinkName = curLink.name;
        if ( curLinkName.indexOf (".png") != -1) {
            var curRectangle = curLink.parent.parent;
            curRectangle.name = NAME_IN_LAYER;
        }
    
}
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
Explorer ,
Feb 21, 2020 Feb 21, 2020
LATEST

Thank you !

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