2 Replies Latest reply on Apr 3, 2016 11:46 PM by marty_76

    Processing a folder of images with Applescript

    marty_76

      Hi everyone

      I am having a problem with my Applescript that I want to open a folder of images and process in PS.

      The script works fine on a single test image whose file path I hard coded to open, but after adding the looping section, I'm not sure I have the right set up to open each image.

      That part of my script is:

       

      set sourceFolder to "Users:etc:etc" as alias

      set destFolder to "/Users/etc:etc"

      --source and destination folders for the images

       

      tell application "Finder" to set imageSet to every file in sourceFolder

       

      tell application "Adobe Photoshop CS6"

        activate

        set ruler units of settings to pixel units

        repeat with i from 1 to (count of imageSet)

        set currentImg to item i of imageSet

        open currentImg

        ....

        (rest of the code to adjust the images)

        ....

        end repeat

      end tell

       

      The error i get is "Finder got an error: document file "(filename)" of folder "(folder name)" (the rest of the file path) of startup disk doesn’t understand the “open” message." when it halts at the 'open currentImg' command

       

      Just wondering if anyone could help me with this? Or offer some code that might work?

      Would be appreciated, as this is the last thing I need to do to finish the script and get the job completed.

       

      Thx in advance

       

      Marty

        • 1. Re: Processing a folder of images with Applescript
          greenrookie Level 3

          Try this.

           

          --Need to use Applescript file paths with colons for Finder

           

          set sourceFolder to "Macintosh HD:Users:etc:etc"

          set destFolder to "Macintosh HD:Users:etc:etc"

           

          --source and destination folders for the images

           

          tell application "Finder"

           

          set imageSet to get every file of folder sourceFolder

          end tell


          tell application "Finder"

                     repeat with i from 1 to (count of imageSet)

                                set currentImg to (item i of imageSet) as string # coerce Finder style path to string

                                tell application "Adobe Photoshop CS6"

                                           activate

                                           set ruler units of settings to pixel units

                                           open alias currentImg # for Photoshop, need to coerce it back to alias!

                                          

                                           #(rest of the code to adjust the images)

                                          

                                end tell

                     end repeat

          end tell

           

           

          Hth,

           

          greenrookie

          • 2. Re: Processing a folder of images with Applescript
            marty_76 Level 1

            greenrookie, you're a champion!

            The script just processed the folder of images- stoked

            The coercions and POSIX path changes you suggested worked perfectly

            Thanks again for your help