9 Replies Latest reply on Nov 27, 2009 3:37 PM by Victor Bushfield

    Script to rename Link Info Names

    Victor Bushfield

      I'm working on converting a clients old catalog from Quark to Indesign.  I'm using Indesign CS4 on Windows Vista. I've used Markzware Q2ID to convert the catalog to indesign with out too many problems.  But I have run into a big problems with the images.  They will not automatically relink.  After digging around I've found the problem.  For some reason all of the Image names also include the path structure.

       

      For Example

       

      Link Info

      Name: BDA-12:Users:graeme:Desktop:FSIP back up:_Collected:02405 FSIP AftMkt EAST:Pictures:M587524.EPS

       

      Path: BDA-12:Users:graeme:Desktop:FSIP back up:_Collected:02405 FSIP AftMkt EAST:Pictures:M587524.EPS

       

      Luckly all the names have the same problem.  So I'm hoping to find or write a script that can simply go through the indesign document and Find/Replace all of the link names to remove "BDA-12:Users:graeme:Desktop:FSIP back up:_Collected:02405 FSIP AftMkt EAST:Pictures:".

       

      I know this is a really simple problem but this is my first real attempt at scripting something in Adobe.  Does anyone have any good ideas or tips on how I would do this?

       

      Thanks

      Vic Bushfield

        • 1. Re: Script to rename Link Info Names
          Peter Kahrel Adobe Community Professional & MVP

          Vic -- Kasyan Servetsky is your man: he has posted several scripts in this forum dealing with this (one of them pretty recently). Search the forum for "Kasyan" and "relink" and you're sure to find something that suits you.

           

          Peter

          1 person found this helpful
          • 2. Re: Script to rename Link Info Names
            Victor Bushfield Level 1

            Great thank you very much.

             

            Sent from my iPhone

            • 3. Re: Script to rename Link Info Names
              Victor Bushfield Level 1

              Okay, I've downloaded his script.  Unfortunatly, this is seems to be one of the few things this script won't do with links.  But it will give me an idea on how to put together a script to remove the string of text from all of the names.

               

              Thanks again.

              • 4. Re: Script to rename Link Info Names
                Kasyan Servetsky Level 5

                 

                Hi Victor,

                 

                 

                I can't be totally sure without seeing your document, but my guess is that your Quark files originate from Mac and you are opening converted files on Windows.

                 

                I offer you the following solutions:

                1. Try to place all links in the same folder (or its subfolder) as indd-files — ID will find missing links.

                 

                2. Use the attached script if links are stored on the server. You should edit it a little: replace

                var myNewPath = myOldPath.replace("OldServer\\FolderName", "NewServer\\FolderName");

                with paths you need.

                 

                Something like this:

                var myNewPath = myOldPath.replace("BDA-12:Users:graeme:Desktop:FSIP back up:_Collected:02405 FSIP AftMkt EAST:Pictures:", "YourServerName\\YourLinksFolderName");

                 

                or for folder Links on your desktop

                var myNewPath = myOldPath.replace("BDA-12:Users:graeme:Desktop:FSIP back up:_Collected:02405 FSIP AftMkt EAST:Pictures:", "~/Desktop/Links");

                 

                 

                Kasyan

                1 person found this helpful
                • 5. Re: Script to rename Link Info Names
                  Victor Bushfield Level 1

                  Kasyan,

                   

                  First of all thanks for taking the time to help me with this.

                   

                  I changed the piece of code you suggested to read as the following.

                   

                          var myNewPath = myOldPath.replace("BDA-12:Users:graeme:Desktop:FSIP back up:_Collected:02405 FSIP AftMkt EAST:Pictures:","C:\Users\Victor\Documents\freelance\Firestone\Projects\EuropeCatalog\cat alog_09\EastPictures\Pictures");

                   

                  But Its still not relinking the images.

                   

                  I believe it has to do with the Name files be screwed up.  I need a similar code to this but that will modify the Name and not the path.  That might fix my problem.

                   

                  I'm going to try modifying your code and see if I can get this to work.

                   

                  I'm also going to attach a small snippit of the catalog I'm working on so that you can see the file.

                  • 6. Re: Script to rename Link Info Names
                    Kasyan Servetsky Level 5

                    Victor,

                     

                    The conversion program totally corrupted links in your document: myLink.filePath is just empty string, myLink.name is what should have been myLink.filePath (This is info from ESTK).

                     

                    Here is a new version of the script -- it relinks to files located in NewLinks folder on the Desktop. Change this line

                    var myNewPath =  "~/Desktop/NewLinks/" + myName;

                    to location of your links.

                     

                    Warning -- I tested this on Mac, since don't have a copy of CS4 for Windows.

                     

                    Kasyan

                     

                    //----------------------------------------

                    #target indesign

                     

                    if (app.documents.length == 0) {
                        err("No open document. Please open a document and try again.", true);
                    }

                     

                    var myDoc = app.activeDocument;
                    var myLinks = myDoc.links;
                    var myCounter = 0;

                     

                    if (myLinks.length == 0) {
                        err("This document doesn't contain any links.", true);
                    }

                     

                    for (i = myLinks.length-1; i >= 0 ; i--) {
                        var myLink = myLinks[i];
                        var myArr = myLink.name.split(":")
                        var myName = myArr[myArr.length-1];
                        var myNewPath =  "~/Desktop/NewLinks/" + myName;
                        var myNewFile = new File(myNewPath);
                        if (myNewFile.exists) {
                            myLink.relink(myNewFile);
                            myCounter++;
                        }
                    }   
                       
                    if (myCounter == 1) {
                        alert("One file has been relinked.", "Finished");
                    }
                    else if  (myCounter > 1) {
                        alert(myCounter + " files have been relinked.", "Finished");
                    }
                    else {
                        alert("Nothing has been relinked.", "Finished");
                    }   

                     

                    function err(e, icon){
                        alert(e, "Update path names script", icon);
                        exit();
                    }

                    • 7. Re: Script to rename Link Info Names
                      Victor Bushfield Level 1

                      Great thanks I will give this a shot when I get home and let you know.  Yes the links were really messed up.  All your help as been really appreciated.

                       

                      Sent from my iPhone

                      • 8. Re: Script to rename Link Info Names
                        Victor Bushfield Level 1

                        Unfortunatly, I am getting the"Nothing has been relinked" response when I execute the script.

                         

                        Here is the script I'm using.  Since it worked for you I'm assuming it has to be a difference between mac/windows.

                         

                         

                        //----------------------------------------

                        #target indesign

                         

                        if (app.documents.length == 0) {
                             err("No open document. Please open a document and try again.", true);
                        }

                         

                        var myDoc = app.activeDocument;
                        var myLinks = myDoc.links;
                        var myCounter = 0;

                         

                        if (myLinks.length == 0) {
                             err("This document doesn't contain any links.", true);
                        }

                         

                        for (i = myLinks.length-1; i >= 0 ; i--) {
                             var myLink = myLinks[i];
                             var myArr = myLink.name.split(":")
                             var myName = myArr[myArr.length-1];
                             var myNewPath =  "C:\Users\Victor\Documents\freelance\Firestone\Projects\EuropeCatalog\catalog_09\EastPict ures\Pictures" + myName;
                             var myNewFile = new File(myNewPath);
                             if (myNewFile.exists) {
                                 myLink.relink(myNewFile);
                                 myCounter++;
                             }
                        }   
                            
                        if (myCounter == 1) {
                             alert("One file has been relinked.", "Finished");
                        }
                        else if  (myCounter > 1) {
                             alert(myCounter + " files have been relinked.", "Finished");
                        }
                        else {
                             alert("Nothing has been relinked.", "Finished");
                        }  

                         

                        function err(e, icon){
                             alert(e, "Update path names script", icon);
                             exit();
                        }

                        • 9. Re: Script to rename Link Info Names
                          Victor Bushfield Level 1

                          Kasyan,

                           

                          Ignore that last post.  I had a few typos and I restarted indesign and now it works perfect.

                           

                          Thanks again for all of your work.

                           

                          Victor