Skip to main content
daanir2168211
Inspiring
May 31, 2019
Question

Automating assignment of buttons file paths

  • May 31, 2019
  • 1 reply
  • 452 views

I have document with multiple buttons that must open files. I changed this script to work with file paths instead of urls: Automating Assignment of Button URLs for DPS Projects | Adobe Developer Connection

But now I have another problem: I have many identical buttons that must open the same files. When creating copy of button, Indesign automaticly renames it, adds number at the end. But even if I rename buttons to have the same name, script dosent work with them. So I need a way to make script work like that: loop throu all of my buttons and if name is something like "Button", "Button 2", "Button 3" give them the same file path as in the my table corresponding with "Button".

Sory for my bad english : ). I don`t know how to script and I need help.

This topic has been closed for replies.

1 reply

Benreyn
Participating Frequently
May 31, 2019

Did you try something like this?

var doc = app.activeDocument;

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

    doc.buttons.name = "Button";

}

This one below will rename all the buttons the same the above script but now will give all buttons the same URL (or file to open):

var doc = app.activeDocument;

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

    doc.buttons.name = "Button";

    doc.buttons.gotoURLBehaviors.item(0).url = "myFilePathAndFileToOpenGoesHere.pdf";

}

daanir2168211
Inspiring
June 3, 2019

Thank you for answer!
The problem is, I have not only identical buttons, but different ones as well. I have document with like 50 different buttons, but six of them repeated 12 times. The script that I found helps me to manage that, except it doesn't work with duplicates.I tried to make loop in the script to cycle thru all button, but got mistake in code.