3 Replies Latest reply on Mar 24, 2013 10:57 AM by booyajamo

    Changing art file names without reimporting?

    RP911

      I have a book project just completed with about 150 pieces of art imported ... the publisher would like the art file names appended with the book title on them. I can do that easily enough in Bridge, but is there a way to accomplish this within InDesign so all 150 won't show up as missing and have to be reimported? Thanks!

        • 1. Re: Changing art file names without reimporting?
          Peter Spier Most Valuable Participant (Moderator)

          I've moved this from the general discussions to the scripting forum. If there's a solution, it's more likely these folks will have it.

          • 2. Re: Changing art file names without reimporting?
            Jump_Over Level 5

            Hi,

             

            I can see 2 ways:

             

            1. you prepare a copies of files with changed names and script could relink all graphics

            2. script could embed each graphic and unembed it to a new file with new name created in a new or chosen folder

             

            both solutions need more info from your side

             

            rgds

            Jarek

            • 3. Re: Changing art file names without reimporting?
              booyajamo Level 1

              Hello,

               

              Here's a solution I used for myself in a similar situation to yours. The approach is similar to what Jarek suggests in #1. This script should relink all graphics including anchored/inline graphics and multiple instances of the same link. It puts the links in the format listed below (which you can change). Assuming your document name is "test.indd":

               

              links are named:

               

              test_originalNameofLink.ext

               

              Lindsay

               

               

              //set active document
              var doc = app.activeDocument;
              
              
              //set document name
              var docName = doc.name.split(".")[0];
              
              
              //set destination folder
              var destFolder = "~/Desktop/test/";
                      
              //count links
              linkCount = doc.links.length;
              
              
              //loop through links
              for (i=linkCount-1; i>=0; i--) {
                  
                  //get current link name
                   var currentLink = doc.links[i];
                   var clFullName = currentLink.name;
                   var clFullNameCount = clFullName.length;
                   var clName = clFullName.split(".")[0];
                   
                   //get current link file path
                   var clFilePath = currentLink.filePath;
                   var clFilePathCount = clFilePath.length;
                   var clFilePathSplitList = clFilePath.split (":");//<--- the colon is specific to mac file paths change to / for windows
                   var clFilePathListCount = clFilePathSplitList.length;
                   var clFileName = clFilePathSplitList[clFilePathListCount-1];
                   var clFileNameCount = clFileName.length;
                   
                   //check for link status
                   if (currentLink.status == LinkStatus.NORMAL) {
                 
                           //set filename without document name
                           var clNameNoPrefix = clFullName;
                           
                           //set relink destination folder & filename
                           var reLinkDest = destFolder + docName + "_" + clNameNoPrefix;
                           
                           //set relink destination file
                           var relinkDestFile = File (reLinkDest);
                                    
                           //check if link is named and relinked
                           if (!relinkDestFile.exists) { 
                               
                               //relink file
                               currentLink.copyLink (new File (reLinkDest));
                               
                               //relink to already existing file
                               } else if (reLinkDest != clFilePath && relinkDestFile.exists) {
                                   
                                   //relink file
                                  currentLink.relink (relinkDestFile);
                                   
                                   };
                           
                            //alert user link is inaccessible
                           } else if (currentLink.status == LinkStatus.LINK_INACCESSIBLE || currentLink.status == LinkStatus.LINK_MISSING || currentLink.status == LinkStatus.LINK_OUT_OF_DATE) {
                               
                               //alert user
                               alert (clFullName + "\n\nThis link is missing, out of date, or inaccessible and can not be updated.")
                               
                               };
              
              
                  };
              
              
              alert ("Done.");