6 Replies Latest reply on Dec 7, 2008 8:54 PM by (Simon_Paterson)

    [AS][CS3] List all images with page numbers

    Jukka Lauhalahti
      Hi!

      I just need a list with all images in a document with page numbers .

      This can be done with preflight report but cleaning it up is tedious.

      Most images are inline graphics so i'm having problem with parent references.

      Thanks
        • 1. Re: [AS][CS3] List all images with page numbers
          Eric @ MCA Level 3
          That is a messier problem than it first looks on the surface because there is no easy way to get the master graphics that may be associated with each page AFAIK. But here is a function that should at least let you determine the page of any object you feed it.


          --Enclose your script in an on run statement
          --Call this with "my findParentPage" if inside a tell app statement
          on findParentPage(thisObject)
          try
            tell application "Adobe InDesign CS2"
             set thisParent to parent of thisObject
             if class of thisParent = page then
              return thisParent
             else if class of thisParent = character then
              -- For characters, must shift to the parent text frame to continue
              my findParentPage(item 1 of parent text frames of thisParent)
             else
              my findParentPage(thisParent)
             end if
            end tell
          on error
            return false
          end try
          end findParentPage
          • 2. Re: [AS][CS3] List all images with page numbers
            Jukka Lauhalahti Level 1
            Hi Eric!

            Thanks for your code, i'll try to work on that and yes, it's a little messy problem.

            Thanks again.
            • 3. Re: [AS][CS3] List all images with page numbers
              (Simon_Paterson) Level 1
              Does the 'all graphics' property suit your purposes? My apologies if I've missed the point of what you were asking, but hopefully the following may help in some way:

              Applescript:
              > tell application "Adobe InDesign CS3"

              tell document 1

              set completeImagesList to {}

              repeat with p from 1 to (count of pages)

              set thisPagesGraphics to all graphics of page p

              repeat with g from 1 to (length of thisPagesGraphics)

              set end of completeImagesList to "Page " & name of page p & ": " & name of item link of (item g of thisPagesGraphics)

              end repeat

              end repeat

              end tell

              end tell

              Javascript:
              >var completeImageList = new Array;

              for (var p = 0; p < app.documents[0].pages.length; p++) {
              var thisPagesGraphics = app.documents[0].pages[p].allGraphics;

              for (var g = 0; g < thisPagesGraphics.length; g++) {

              completeImageList.push("Page " + app.documents[0].pages[p].name + " " + thisPagesGraphics[g].itemLink.name);

              }

              }

              }


              You should end up with an array that contains all the image names and page numbers. You can put that into a new document with something like, although I'm sure you could come up with something far more elegant than this:

              >tell (make new document)
              tell page 1
              set myFrame to make new text frame with properties {geometric bounds:{0, 0, 5, 5}}
              set theDelims to AppleScript's text item delimiters
              set AppleScript's text item delimiters to "\r"
              set contents of insertion point 1 of parent story of myFrame to completeImagesList as string
              set AppleScript's text item delimiters to theDelims
              end tell
              end tell
              • 4. Re: [AS][CS3] List all images with page numbers
                Jukka Lauhalahti Level 1
                Hi Simon!

                I'm AFK awhile but thank you for your reply.

                I need to have a list of all images imported (eps, jpg, tiff etc) and their page numbers.

                When i'm back at office i'll look into your code.

                Thanks again!
                • 5. Re: [AS][CS3] List all images with page numbers
                  Jukka Lauhalahti Level 1
                  Simon!

                  Beautiful code, simple, efficient and incrediple fast!

                  Did some minor changes and now i'm able to do imagelists of 3000+ images in seconds comparing hours with preflight report.

                  YOURS truly

                  jukka