2 Replies Latest reply on Aug 1, 2012 5:58 AM by OzSanta2

    Requesting help regarding 'Batch' script

    OzSanta2

      G'day

       

      Elsewhere in this forum I posted a script using the Photoshop 'Batch' command.

       

      Trouble is, it won't work  under PS CS5 or CS6 extended trial. and gives the following error for both...

       

      Screen Shot 2012-08-01 at 9.00.32 AM.png

       

      My script is...

       

      on adding folder items to this_folder after receiving PhotoshopFiles

                try

                          set ptd to path to desktop as text

        --set ptdpp to ptd & "Photoshop Processing" as text

                          set ptdpp to this_folder as text

                          set ptdpif to ptd & "Processed Images Folder" as text

                          set ptdpsf to ptd & "Processed Stored Folder" as text

                          set fileToLog to (ptdpif) & ":Photoshop_Batch_Errors_Log.txt" as text

                          tell application "Finder"

       

                                    if not (exists folder ptdpsf) then

                                              make new folder at folder ptd with properties {name:"Processed Stored Folder"}

                                    end if

                                    if not (exists folder ptdpif) then

                                              make new folder at folder ptd with properties {name:"Processed Images Folder"}

                                    end if

                                    if not (exists file fileToLog) then

                                              make new file at folder ptdpif with properties {name:"Photoshop_Batch_Errors_Log.txt"}

                                    end if

                                    set PhotoshopFiles to files of folder ptdpp as alias list

       

                          end tell

        say (count of PhotoshopFiles)

       

                          tell application "Adobe Photoshop CS5"

        activate

                                    set display dialogs to never

        batch "Wood Frame - 50 pixel" from "Default Actions" from files PhotoshopFiles with options {destination:folder, destination folder:alias ptdpif, error file:alias fileToLog, macintosh compatible:true, file naming:{document name mixed, extension lower}, suppress open:true, override save:true}

                          end tell

       

                          tell application "Finder"

        move PhotoshopFiles to folder ptdpsf

                          end tell

                on error errmsg

        display dialog errmsg

                end try

       

      end adding folder items to

       

       

      Am I coding the Batch command correctly please?

       

      Regards

       

      Santa

        • 1. Re: Requesting help regarding 'Batch' script
          JJMack Most Valuable Participant

          OzSanta2 wrote:

           

          G'day

           

          Elsewhere in this forum I posted a script using the Photoshop 'Batch' command.

           

          Trouble is, it won't work  under PS CS5 or CS6 extended trial. and gives the following error for both...

           

          Screen Shot 2012-08-01 at 9.00.32 AM.png

           

          My script is...

           

          Am I coding the Batch command correctly please?

           

           

          The Automate Batch Command batches an actiom which I assume you created and it in turn uses your script. You get that message during the batch command. However you give us no clue as to when you get that message  have images file been open or saved or how you setup the batch dialog to run your action that uses your apple script.  I myself use a pc.  You may want to try putting some alerts in you script to see if you can narrow the problen down to some section in your script.

          • 2. Re: Requesting help regarding 'Batch' script
            OzSanta2 Level 1

            Thanks JJMack

             

            Turns out, from Apples Applescript Users Group, that Adobe document everything to use the Batch command, but don't actually use or support it, nor have they for several iterations of Photoshop.

             

            Instead, I had to resort to other means to do the job, namely a do action. Here's the script. Note that in some actions, the command to turn off 'display dialogs' doesn't always work. Another Adobe slipup.

             

             

            -- Photoshop Action Script

             

            -- by Brian Christmas

             

            -- August 2012

             

            global ptdpp

            global ptdpif

            global ptdpsf

            global fileToLog

            global file_to_save

            global file_Name2

            global file_Extension

            property PhotoshopFiles : {}

             

            on adding folder items to this_folder after receiving tempPhotoshopFiles -- we don't really want these, in case  there's more in the folder that did not trigger the Folder Action, a common occurrance

                      try

                                set ptd to path to desktop as text

                                set ptdpp to this_folder as text

                                set ptdpif to ptd & "Processed Images Folder" as text

                                set ptdpsf to ptd & "Processed Stored Folder" as text

                                set fileToLog to (ptdpif) & ":Photoshop_Batch_Errors_Log.txt" as text

                                my makeNewFolders()

                                set SayThis to " files"

                                if (count of PhotoshopFiles) = 1 then set SayThis to " file"

              say (count of PhotoshopFiles) & SayThis as text

                                tell application "Adobe Photoshop CS6"

                                          repeat with this_File in PhotoshopFiles

                                                    my resetFirstFolder(this_File)

              open this_File

                                                    try

              do action "Wood Frame - 50 pixel" from "Default Actions" without notifiers enabled and display dialogs -- < this particular action brings up a dialog box which can't be addressed with Applescript

              save current document in file file_to_save with copying -- < set to 'without copying' if original files not required

                                                    on error errmsg

              display dialog errmsg -- < write to ":Photoshop_Batch_Errors_Log.txt" here

                                                    end try

                                                    try

              close document 1 saving no

                                                    end try

                                                    my resetSecondFolder(this_File)

                                          end repeat

                                end tell

                      on error errmsg

              display dialog errmsg

                      end try

            end adding folder items to

             

            on makeNewFolders()

                      tell application "Finder"

                                if not (exists folder ptdpif) then

                                          make new folder at folder ptd with properties {name:"Processed Images Folder"}

                                end if

                                if not (exists folder ptdpsf) then

                                          make new folder at folder ptd with properties {name:"Processed Stored Folder"}

                                end if

                                if not (exists file fileToLog) then

                                          make new file at folder ptdpif with properties {name:"Photoshop_Batch_Errors_Log.txt"}

                                end if

                                set PhotoshopFiles to every file of folder ptdpp as alias list -- These are the files we want, every one in the folder

                      end tell

            end makeNewFolders

             

            on resetFirstFolder(this_File) -- ALL saved as default .psd files

                      tell application "Finder"

                                set file_Name to name of this_File

                                set file_Extension to "psd" --default Save name extension of this_File, will require altering if default is reset eg to jpeg

                                set file_Name2 to characters 1 through -((count of file_Extension) + 2) of file_Name as text

                                set file_to_save to (ptdpif & ":" & file_Name2 & "." & file_Extension as text)

                                set x to 1

                                repeat

                                          if not (exists file file_to_save) then exit repeat

                                          set file_to_save to (ptdpif & ":" & file_Name2 & " " & x & "." & file_Extension as text)

                                          set x to x + 1

                                end repeat

                      end tell

            end resetFirstFolder

             

            on resetSecondFolder(this_File) -- ALL saved in original name extensions

                      tell application "Finder"

                                set file_to_store to (ptdpsf & ":" & file_Name2 & "." & file_Extension as text)

                                set file_Extension to name extension of this_File

                                set x to 1

                                repeat

                                          if not (exists file file_to_store) then exit repeat

                                          set file_to_rename to (ptdpsf & ":" & file_Name2 & " " & x & "." & file_Extension as text)

                                          if not (exists file file_to_rename) then

                                                    set name of file file_to_store to (file_Name2 & " " & x & "." & file_Extension as text)

                                                    exit repeat

                                          end if

                                          set x to x + 1

                                end repeat

                                try

              move this_File to folder ptdpsf

                                on error

                                          try

              move this_File to folder ptdpsf with replacing

                                          on error errmsg

              display dialog errmsg -- < write to ":Photoshop_Batch_Errors_Log.txt" here

                                          end try

                                end try

                      end tell

            end resetSecondFolder