Skip to main content
Known Participant
November 19, 2009
Question

hyperlinks in a csv file

  • November 19, 2009
  • 1 reply
  • 343 views

Is this possible,

I have a Indesign file with lots of web links in, but they are all wrong!

So I have a CSV file with column A the wrong links, and column B the right links, can this be scripted, to automate the changing of the links from wrong to right?

This was for another link issue to do with links which worked very well.

http://forums.adobe.com/thread/432905?tstart=0

Any help would be great, even if that means it can't be done!

Cheers!

This topic has been closed for replies.

1 reply

Known Participant
November 20, 2009

Hi jamb71,

I suppose you could read the two collumns into arrays with javascript.

This have not been tested:

var myDocument = app.documents.item(0);
var LinksA = new Array();
LinksA[0] = "Old Value 0";
LinksA[1] = "Old Value 1";
LinksA[2] = "Old Value 2";
var LinksB = new Array();
LinksB[0] = "New Value 0";
LinksB[1] = "New Value 1";
LinksB[2] = "New Value 2";

for (i=0;i<LinksA.length;i++) {
     //LnksA
     var findWhat = LinksA;
     var changeTo = LinksB;
     
     if(myDocument.hyperlinkURLDestinations.length > 0){
          for(var myCounter = myDocument.hyperlinkURLDestinations.length -1; myCounter >=0; myCounter--){
               myDestinationURL = myDocument.hyperlinkURLDestinations.item(myCounter).destinationURL;
               if(myDestinationURL.search(findWhat) != -1){
                    myDocument.hyperlinkURLDestinations.item(myCounter).destinationURL = myDestinationURL.replace(findWhat, changeTo);
               }
          }
     }
}

--

molsted