13 Replies Latest reply on Dec 1, 2010 5:53 AM by Dargon Kong

    Batch update links script?

    prepress21 Level 1

      Does anyone have a script that will auto update the links in several InDesign documents? I have 121 InDesign documents that each have two updated .ai files. When I open they ask if I want to update. I need a script that tells each one yes to update and save.

       

      I would also like to export a pdf of each file. Being able to chose my preset and overwrite the existing pdf. Batch process of course.

       

      Thanks!

        • 1. Re: Batch update links script?
          sudar1983_14 Level 2

          Please see the below script, which will update all links and it will generate ps file using your printpreset. Once the ps is generated you can drag into acrodistiller.

           

          var printPreset;
          var printPresetPath="D:\\Books\\Preset.prst";
          var inputDirectory="D:\\IndFiles";
          var inddFiles=new Array();

           

          inddFiles=Folder(inputDirectory).getFiles();

           

          //Suppress all dialogs
          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

           

          for(var indCount=0; indCount < inddFiles.length; indCount++)
          {
              if (String(inddFiles[indCount]).match(/\.indd$/i))
              {
                  var aDoc=app.open(File(inddFiles[indCount]), true);
                 
                  //Links update
                  aDoc.links.everyItem().update();
                 
                  //Removing existing printpresets
                  for(var pP=0; pP < app.printerPresets.length; pP++)
                  {
                      var myprintPreset = app.printerPresets.item(pP);
                      if (String(app.printerPresets.item(pP).name) != '[Default]')
                      {
                          myprintPreset.remove();
                      }
                  }
                 
                  //Adding our print preset
                  printPreset=File(printPresetPath);
                  app.importFile(1918071916, printPreset);
                  myprintPreset=app.printerPresets.lastItem();
                 
                  //Generating PS in the application path
                  myprintPreset.printFile = File(aDoc.filePath+'/'+String(aDoc.name).substr(0, (String(aDoc.name).length-5))+'.ps');
                  aDoc.print(false, myprintPreset);
             
                  //Save and close
                  aDoc.close(2036691744);
              }
          }

           

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

           

           

          Arivu....

          • 2. Re: Batch update links script?
            Dargon Kong Level 1

            I wanna know is there possible to have a script  that can batch update links of open files. Just update the links. Though, you have written some code here. But I don't how to use it. I have been searched it for a very long time.

            And I want to learn something about indesign script. But I don't know where to start. Only indesign script. Could you show me what to do?

             

            Thank you in advance.

            • 3. Re: Batch update links script?
              [Jongware] Most Valuable Participant

              How to install and use scripts into your Indesign: http://indesignsecrets.com/how-to-install-scripts-in-indesign.php

               

              General starting info and guides: http://www.adobe.com/products/indesign/scripting/ -- click the Scripting Resources tab, then download the Introduction, Tutorial, and In-Depth guide for your version of InDesign.

              • 4. Re: Batch update links script?
                Dargon Kong Level 1

                Maybe I didn't make myself clear. My poor English. I do know how to use scripts in indesign. What I mean is when I click the script above, nothing happens. I did what you guided me before, three pdfs, and I do not know what to do. You know what to do about indesign scripting and where to start, right?

                • 5. Re: Batch update links script?
                  Kasyan Servetsky Level 5

                  Check out this script. It opens each InDesign document in the selected folder, updates all outdated links, saves and closes it.

                   

                  Kasyan

                  • 6. Re: Batch update links script?
                    Dargon Kong Level 1

                    Though it doesn't work. Thank you all the same.

                    • 7. Re: Batch update links script?
                      Kasyan Servetsky Level 5

                      I retested the script and it works for me (I am on CS3 for Windows). You want to update all modified links in all open documents, don't you? Did I get you right?

                       

                      Kasyan

                       

                      if (app.documents.length == 0) {
                           alert("Please open a document and try again.");
                           exit();
                      }
                      
                      var docs = app.documents;
                      
                      for (var i = 0; i < docs.length; i++) {
                           UpdateAllOutdatedLinks(docs[i]);
                      }
                      
                      alert("Finished");
                      
                      function UpdateAllOutdatedLinks(doc) {
                           for (var d = doc.links.length-1; d >= 0; d--) {
                                var link = doc.links[d];
                                if (link.status == LinkStatus.linkOutOfDate) {
                                     link.update();
                                }
                           }
                      }
                      
                      • 8. Re: Batch update links script?
                        Dargon Kong Level 1

                        Yes. Yes. That's what I mean. You are great. Thank you so much. It works well in CS2 and CS4 also. BTW, I want to learn how to write script. Should I start from a Java book? Could you kindly recommend?

                        • 9. Re: Batch update links script?
                          AdobeScripts Level 3

                          Though it doesn't work. Thank you all the same.

                          "Batch update links

                          Script for InDesign CS3/4, version 1.0."

                           

                          What version of InDesign do you have ?

                           

                          robin

                          www.adobescripts.co.uk

                          • 10. Re: Batch update links script?
                            Dargon Kong Level 1

                            Thanks so much. I already got what I want above.

                            • 11. Re: Batch update links script?
                              AdobeScripts Level 3

                              Thanks so much. I already got what I want above.

                               

                              Fine, but please - next time - tell us what version of InDesign you have.

                               

                              robin

                              www.adobescripts.co.uk

                              • 12. Re: Batch update links script?
                                Kasyan Servetsky Level 5

                                BTW, I want to learn how to write script. Should I start from a Java book? Could you kindly recommend?

                                Here's a list of resources I recommend to first-time scripters, and here's a list of links where you can find information on more advanced topics. I also recommend you strongly to download and use Jongware's InDesign JavaScript Reference Guide -- it's much better than the built-in Object Model Viewer. And don't confuse Java with JavaScript --  these are totally different programing languages -- the latter is used for writing scripts for InDesign and some other adobe applications.

                                 

                                Kasyan

                                • 13. Re: Batch update links script?
                                  Dargon Kong Level 1

                                  Thank you all very much. You guys are so warm-hearted to help. Next time, I will tell as more details as I can.