4 Replies Latest reply on Apr 17, 2008 4:39 AM by (Matt_McGregor)

    {AS, CS] Placing a folder of images into InDesign

    Level 1
      Hi All,

      Working on a script that allows for a folder of images to be nominated then a document created with one image placed per page.

      Here's the script so far:

      ** Applescript - Paste into script editor **

      -- Determine source folder of images to be placed
      tell application "Finder"
      -- Select source folder
      set srcfolder to choose folder with prompt "Select a folder of images to place in Indesign"

      -- Count the number of images to place
      set imageqty to count every item of folder srcfolder
      -- display dialog imageqty & " images to place" as string giving up after 2

      -- Create list of images to place
      set PicList to every item of folder srcfolder

      end tell

      tell application "InDesign CS"
      activate

      -- Document Creation
      set myDoc to make document
      tell document preferences of myDoc
      set page height to "297mm"
      set page width to "210mm"
      set page orientation to portrait
      set pages per document to imageqty
      end tell

      -- Set Master Page Margins / Create picture box
      tell page 1 of master spread 1 of myDoc

      tell margin preferences
      set top to 0
      set left to 0
      set bottom to 0
      set right to 0
      end tell
      set mypicbox to make rectangle with properties {geometric bounds:{"10mm", "10mm", "287", "200mm"}}
      end tell

      -- Override rectangle of every page to allow for image to be placed
      tell myDoc
      repeat with i from 1 to imageqty
      set applied master of page i to master spread "A-Master"
      override rectangle 1 of master spread 1 destination page page i
      end repeat
      end tell

      set ppnum to 1


      -- Place images one page at a time from List
      repeat with thisitem in PicList
      -- display dialog thisitem as string
      -- override rectangle picboxnum of master spread 1 destination page page 1


      place thisitem on rectangle 1 of page ppnum
      -- Thanks Shane Stanley Adobe Forums - for "on rectangle"

      fit rectangle 1 given center content
      -- Thanks Shane Stanley Adobe Forums - for "given center content"

      set ppnum to (ppnum + 1)
      end repeat

      end tell

      The script creates the correct number of pages based on the images selected , but doesn't understand the "place thisitem on rectangle 1 of page.. " command. Error generated is: "InDesign CS got an error: Can't get rectangle 1 of page 1."

      There is only ONE rectangle on page 1. What am I doing wrong here?

      If there is a standing / example script to do what I'm trying to achieve here I'd be grateful.

      Ps. I have the Adobe InDesign Applescript Guide Pdf which is very useful but there is next to nothing in the 175pp guide that covers working with images and links. Is there another reference somewhere covering images in InDesign?

      Thanks in Advance.

      Matt.

      MacOS : 10.3.9
      Applescript : 1.9.3
      InDesign CS : 3.0.1