Copy link to clipboard
Copied
Hi All,
I am looking for a way to batch rename hyperlinks in my In Design files. Currently I have Hyperlinks linking every product in a printed catalog to the the product page on the web. However we have websites in 3 countries, so I want to be able to change all the .coms to .au and then again to .ca. Previously we have been achieving this by exporting the idml file and then find and replace in the design map text file. However, when I reopen the idml files this year the same way I did last year they are completely blank in Indesign.
Copy link to clipboard
Copied
Maybe something has changed in your IDML editing process (different text editor etc.)
As a test, try to open the appropriate design map file and manually change just one link, then open IDML in InDesign. Will it work?
Copy link to clipboard
Copied
I canged just one and it opened correctly in InDesign. I checked the one that I canged to see it the change to the hyperlink carried over and it did.
Copy link to clipboard
Copied
Then it looks like something is going amiss during your batch-replace process. Maybe the text editor inserts some invisible characters or something else. Try a different text editor; make sure it only produces plain text and not RTF or something like this.
Copy link to clipboard
Copied
Thank you! I tried it again and replaced 100 of them by just pressing the "replace" button over and over. Not presing the "replace all" So now I will just play with it. I have over 10,000 PNs so hoping I do not have to press the darn button that many times!!! lol
Copy link to clipboard
Copied
Although I was just given a script, I figured it out. At the begining of the design map adobe had this: <Document xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging" it was also changing their .com to.ca in the find and replace. I manualy changed it back and the idml was intact when I opened it again.
Copy link to clipboard
Copied
This is fairly easy to script in InDesign itself, no need for the IDML-roundtrip (this version changes .com to .au):
// Change .com to .au
var h = app.activeDocument.hyperlinks.everyItem().getElements();
for (var i = h.length-1; i >= 0; i--) {
currentURL = h[i].destination.destinationURL;
if (h[i].destination instanceof HyperlinkURLDestination
&& /\.com$/.test (currentURL)) {
h[i].destination.destinationURL = currentURL.replace(/(.+\.)(.+)$/,'$1au');
}
}
This version changes .com to .au.
It changes just the destination URL. If the source text and/or the link's name in the Hyperlinks panel are also the link name you need some additional code.
Copy link to clipboard
Copied
Thank you! We have beeen looking for a better way!