4 Replies Latest reply on May 10, 2014 3:08 AM by Atiqur Sumon

    Can't get this droplet to save a JPEG...


      I'm getting an error that it can't find the document after it's opened. The actions seem to run just fine, but it stops short of actually saving the file into the newly created folder. It also doesn't close the last document.


      Can anyone find a problem with my script? I seem to have hit a brick wall here.

      (I'm running Photoshop CS6.)


      on open mgItems

           set myDate to (get current date)

           set y to year of myDate as text

           set m to month of myDate as integer

           set d to day of myDate as integer

           if d < 10 then

                set d to "0" & d as text


                set d to d as text

           end if

           if m < 10 then

                set m to "0" & m as text


                set m to m as text

           end if

      set y to text -2 thru -1 of y

      set myReleaseDate to y & m & d & "_iPadResized"


      repeat with mgThisItem in mgItems

           tell application "System Events"

                set targetFolderPath to path of container of disk item (mgThisItem as text)

           end tell


           tell application "Adobe Photoshop CS6"



                     open mgThisItem

                set mgDocName to name of current document

                set text item delimiters of AppleScript to ".tif"

                set mgShortName to text item 1 of mgDocName


                set mgPackageFilePath to targetFolderPath & myReleaseDate


                my createFolders(POSIX path of file (mgPackageFilePath))


                set display dialogs to never

                set thisdoc to current document

                set docHeight to height of thisdoc

                set docWidth to width of thisdoc

                tell thisdoc

                     flatten document

                     if docHeight / docWidth > 0.75 then

                          do action "iPad_tall" from "iPad Resize"


                          do action "iPad_wide" from "iPad Resize"

                     end if

                     save in file mgPackageFilePath as JPEG with options {quality:12}

                end tell

                close the current document saving no

             on error e

                  display dialog e

             end try

        end tell


      end repeat

      display dialog "Files resized for iPad"

      end open


      on createFolders(pathString)

           do shell script "mkdir -p " & quoted form of pathString

      end createFolders