3 Replies Latest reply on Jan 13, 2010 2:21 AM by AdobeScripts

    Find image by name

    René Mølsted Level 1

      Hi all,

      is it possible to find linked image by name, say find all images named 4535df55_lm.jpg?

       

       

      --

      René

        • 1. Re: Find image by name
          AdobeScripts Level 3

          René Mølsted wrote:

           

          Hi all,

          is it possible to find linked image by name, say find all images named 4535df55_lm.jpg?

          There is Links collection in Document.

           

          VisualBasic example:

           

          For a=1 to myDoc.Links.Count

          If myDoc.Links.Item(a).Name = "aaa.tif" Then

          ' do something

          End If

          Next

           

          robin

          www.adobescripts.co.uk

          1 person found this helpful
          • 2. Re: Find image by name
            René Mølsted Level 1

            Hi,

            I ended up doing the following:

             

            var theStoriesPage = app.documents.item(0);
            
            for (all=0; all<theStoriesPage.allGraphics.length; all++) {
                 mLinkName = theStoriesPage.allGraphics[all].itemLink.name
                 if (mLinkName.match("\\d{8}") && mLinkName.match(".pdf")) {
                      // doing my thing
                 }
            }
            

             

            I just hoped there was some way to avoid the for-loop. Some documetns contains 4000+ images - that takes a while

             

             

            --

            René

            • 3. Re: Find image by name
              AdobeScripts Level 3

              René Mølsted wrote:

              var theStoriesPage = app.documents.item(0);
              
              for (all=0; all<theStoriesPage.allGraphics.length; all++) {
                   mLinkName = theStoriesPage.allGraphics[all].itemLink.name
                   if (mLinkName.match("\\d{8}") && mLinkName.match(".pdf")) {
                        // doing my thing
                   }
              }
              

               

              I just hoped there was some way to avoid the for-loop. Some documetns contains 4000+ images - that takes a while

              Don't iterate allGraphics collection - iterate Links collection - should be faster.

              Or - I'm not JS man - maybe would be faster if you first get all names by using everyItem and then you will check array of names ? Index in array will be equal to link's position in Links collection.

               

              robin

              www.adobescripts.co.uk