1 Reply Latest reply on Nov 20, 2009 4:50 AM by René Mølsted

    hyperlinks in a csv file


      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.



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





        • 1. Re: hyperlinks in a csv file
          René Mølsted Level 1

          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++) {
               var findWhat = LinksA[i];
               var changeTo = LinksB[i];
               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);