Copy link to clipboard
Copied
Hi there,
I've searched through the forums and have not been able to find or put together a script that suits my needs. I have an Indesign document with hundreds of URL hyperlinks linked to invisible rectangles, and I want to be able to view all the URLs in a list (all at once, or from a specified page range) in a window and edit them there instead of having to go to each page to Edit Hyperlink. All the URLs are unique so mass Find/Replace scripts are not useful to me.
Is a script possible for my needs, or is there an alternative option such as using IDML? I'm on a Mac if that makes any difference!
Thanks in advance!
Copy link to clipboard
Copied
I'd probably approach it as two separate scripts. The first main would get you a txt file to your desktop of all the URLs. The second would read and replace from that file. Could also get the hyperlinked item's page and sort that way once the txt is generated:
var main = function() {
var f = File(Folder.desktop + "/hyperlink_log.txt");
f.encoding = "UTF-8";
f.open("w");
var d = app.activeDocument;
var hls = d.hyperlinks;
var i = hls.length;
while(i--) {
try {
f.writeln(hls[i].name + "\t" + hls[i].hyperlinkURLDestination.destinationURL);
} catch(e) { /*not a url*/ }
}
f.close();
}
var main2 = function() {
var f = File(Folder.dektop + "/hyperlink_log.txt");
var d = app.activeDocument;
f.encoding = "UTF-8";
f.open("r");
var l;
while(!f.eof) {
try {
l = f.readln().split("\t");
d.hyperlinks.itemByName(l[0]).hyperlinkURLDestination.destinationURL = l[1];
} catch(e) {}
}
f.close();
}
Copy link to clipboard
Copied
I'll give this a try - thank you!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I need to edit the URL of each hyperlink. They're all unique hyperlinks so I cannot use a simple Find/Replace script. Hence why I was hoping I could pull all the URLs up in a certain window and edit them there without having to go to each box to right-click and edit the hyperlink 🙂 Thanks!