3 Replies Latest reply on Jul 16, 2009 6:06 PM by Eric @ MCA

    Applescript pagination

    MVarner

      I at the IT Director for a local newspaper and I have been asked to develop an applescript that would open an Indesign CS4 document and import the daily comic strips into the page.  The comics are tiff files.  The comics files have a 3 or four character abbrevation of their name and a four digit date such as abc0715.   Any help would be greatly appreciated.

        • 1. Re: Applescript pagination
          liedzeit Level 2

          The problem with this kind of question is that it asks for a complete script and is vague at the same time.

          You should go through the documentation and start with the simple things. How to open a document, how to create items and then come back with specific questions.

           

          This places a comic strip:

           

           

           

          
          tell application "Adobe InDesign CS4"
               set dailycomic to "Macintosh HD:abc0715.tif"
               set mydoc to open "Macintosh HD:mydaily.indd"
               tell mydoc
                    tell page 1
                       set myrect to make rectangle with properties {geometric bounds:{15, 15, 80, 190}}
                        tell myrect
                             set myGraphic to place (dailycomic as string)
                        end tell
                    end tell
               end tell
          end tell
          
          
          

           

           

           

          But you can see that there are a couple of open questions. What doc to open? Where to place the comic? How to find the right comic? Is the date in the comic somewhere in the name of the ID document? Etc,

           

          Hope this helps anyway.

          Ralf

           

          Edit: put the red into quotes. :-)

          1 person found this helpful
          • 2. Re: Applescript pagination
            MVarner Level 1

            Thanks for the preious post.  It was actually very helpful.

             

            I now have the script opening my indesign page, creating rectangles and placing the images in the rectangels and resizing them to fit the box.

             

            I am hardcoding the names of the files that are being placed.  They all start with 2 or 3 characters followed by some type of date.  The dates from from 4 digits to 8 digits.   Is it possible to use a wildcard in applescript to identify the files?

             

            Also my template has existing frames for the graphics.  Is it possible to use them and not have the script create new rectangles?

             

             

             

            Here is what I have working so far.

             

            tell application "Adobe InDesign CS4"

                  set comic1 to "Macintosh HD:users:marshall:documents:comics:bbt20090713.tiff"

                  set mydoc to open "Macintosh HD:users:marshall:documents:comix:GGDailyBlank.indd"

                  tell mydoc

                         tell page 1

                               set myrect to make rectangle with properties {geometric bounds:{30.6, 2.4, 41, 32.5}}

                               tell myrect

                                     set myGraphic to place (comic1 as string)

                               end tell

                         end tell

                  end tell

            end tell

             

            Thanks for the help.

             

             

            Marshall

            • 3. Re: Applescript pagination
              Eric @ MCA Level 3

              It's probably best to get a list of files in the folder and then try to work from there.

               

              tell application "Finder"

              set comicsFolder to path to documents folder as text

              set comicsFolder to comicsFolder & "comics:"

              set fileList to name of every file of folder comicsFolder whose name extension = "tiff"

               

              set myYear to do shell script "date '+%y'"

              set myMonth to do shell script "date '+%m'"

              set myDate to do shell script "date '+%d'"

               

              set nameOptions to {"bbt20" & myYear & myMonth & myDay&".tiff", "bbt"&myYear&myMonth&myDay"&".tiff", "etc"}

               

              set todaysName to "MISSING"

              repeat with thisName in nameOptions

                 if fileList contains thisName then

                    set todaysName to thisName

                 end if

              end repeat

              end tell

               

              tell application "Adobe InDesign CS3"
                  if todaysName ≠ "MISSING" then

                      set comicPath to "" & comicsFolder & todaysName
                      --do stuff

                  else

                      display dialog "Can't find comic!" buttons "Cancel" default button 1
                  end if
              end tell

               

              Also, if you have a template you are working from, investigate Script Labels.

               

              Then you can put your graphic box in the right spot on the page, set the script label to "comic" and just place the graphic in the box whose label  = "comic".