3 Replies Latest reply on Sep 15, 2016 9:53 PM by tpk1982

    Find out which documents a link appears in

    jakec88782761 Level 1

      Hello everyone,

       

      I've got a question that may not be possible.

       

      Is it possible to find out the names of documents that a single link appears in?

       

      I'd like to do this on a selection (app.selection[0]), however I don't think the links property allows it.

       

      var links1 = app.activeDocument.links;

      alert(links1[0]);

       

      From what I can tell from this script, links is an array.

       

      I have no idea if what I want to do is possible but any advice would be great

       

      Thanks everyone!

        • 1. Re: Find out which documents a link appears in
          tpk1982 Level 4

          Yes it can be do.. your requirement is need to know the document name if it consists only one link, isn't it?

          • 2. Re: Find out which documents a link appears in
            jakec88782761 Level 1

            I need to know the names of all the documents that the link appears in.

             

            For example:

             

            If I have an image linked into a document,

            then, I link the same image to a different document.

             

            I want a script that tells me the names of both documents, as both have the linked image within them.

            • 3. Re: Find out which documents a link appears in
              tpk1982 Level 4

              try this.. replace the image name in line 8.. i used "x.ai"

               

               

              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
              var inputFolder = Folder.selectDialog("Select a folder for the Flatness check");
              myarray=[];
              if (inputFolder != null) {
                  var fileList = inputFolder.getFiles(/\.(indd)$/i);
                 for (var i = 0; i < fileList.length; i++) {
                        var docRef=app.open(File(fileList[i]));
                     if(docRef.allGraphics[i].itemLink.name.match("x.ai")){
                         myarray.push(docRef.name);
                      docRef.close();
              
              
                      }
                  }
              }
              alert(myarray.join("\r"))
              

               

               

              Thanks,

              K