2 Replies Latest reply on Dec 2, 2010 8:12 AM by Christian Harder

    Any way to export several columns from the Links panel?

    Christian Harder

      This was originally posted to the InDesign forum, was suggested there might be a script that could achieve this?

       

      Working on a textbook with hundreds of illustrations. Each Chapter has  up to 100.  Need to get several columns of data (file name and page #  that it appears on) exported from the Links Panel (in sorted order) so  they can be dropped into a spreadsheet. I am using TextWrangler which  will dump out all the filenames in a folder, but it sorts alphabetically  and I really want them sorted by the Page Numbers where they appear.

        • 1. Re: Any way to export several columns from the Links panel?
          Kasyan Servetsky Level 5

          This script creates a CSV file on the desktop that you can import in Excel. The file name is the same as the name of active indesign document.

           

          Kasyan

           

          var scriptName = "Generate list of links";
          if (app.documents.length == 0) ErrorExit("No documents are open. Please open a document and try again.");
          
          var page, allGraphics, graphic;
          var text = "File name;Page\r";
          var doc = app.activeDocument;
          
          for (var i = 0; i < doc.pages.length; i++) {
               page = doc.pages[i];
               allGraphics = page.allGraphics;
               for (var k = 0; k < allGraphics.length; k++) {
                    graphic = allGraphics[k];
                    if (graphic.itemLink != null) {
                         text += graphic.itemLink.name + ";" + page.name +"\r";
                    }
               }
          }
          
          WriteToFile(text);
          
          //-------------------------------------- FUNCTIONS ---------------------------------------------
          function WriteToFile(text) {
               var theFile = new File("~/Desktop/" + GetFileNameOnly(doc.name) + ".csv");
               theFile.open("w");
               theFile.write(text); 
               theFile.close();
          }
          //--------------------------------------------------------------------------------------------------------------
          function ErrorExit(error, icon) {
               alert(error, scriptName, icon);
               exit();
          }
          //--------------------------------------------------------------------------------------------------------------
          function GetFileNameOnly(myFileName) {
               var myString = "";
               var myResult = myFileName.lastIndexOf(".");
               if (myResult == -1) {
                    myString = myFileName;
               }
               else {
                    myString = myFileName.substr(0, myResult);
               }
               return myString;
          }
          //--------------------------------------------------------------------------------------------------------------
          
          • 2. Re: Any way to export several columns from the Links panel?
            Christian Harder Level 1

            Thanks. I'll try it for fun, I was working in CS4, but I just found out CS5 now has an option in the Links panel fly-out "Copy Info for Selected Records". That does the trick.