As I hate it, I dropped calls to Finder.
I trigger System Events plus a Shell Script because I was never able to get the System Events Move command working.
-- 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"
set ptdpsf to ptd & "Processed Stored Folder"
set fileToLog to (ptdpif) & ":Photoshop_Batch_Errors_Log.txt"
my makeNewFolders()
(*
Here, PhotoshopFiles is a list of strings containing the pathnames of original files (possibly not PSD ones).
*)
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
(*
this_File is a string containing the pathname of an original file (possibly not PSD one).
*)
my resetFirstFolder(this_File)
(*
As I use System Events, this_File is a string so I assume that we must at least coerce it as file
*)
open file 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 -- to Photoshop
on error errmsg
display dialog errmsg
end try
end adding folder items to
on makeNewFolders()
tell application "System Events"
if not (exists folder ptdpif) then
make new folder at end of folder ptd with properties {name:"Processed Images Folder"}
end if
if not (exists folder ptdpsf) then
make new folder at end of folder ptd with properties {name:"Processed Stored Folder"}
end if
if not (exists file fileToLog) then
make new file at end of folder ptdpif with properties {name:"Photoshop_Batch_Errors_Log.txt"}
end if
set PhotoshopFiles to path of file of folder ptdpp whose visible is true -- build a list of strings
end tell -- to System Events
end makeNewFolders
on resetFirstFolder(this_File) -- ALL saved as default .psd files
tell application "System Events"
set file_Name to name of file this_File -- file_Name IS a text item
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
set file_to_save to ptdpif & ":" & file_Name2 & "." & file_Extension
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
set x to x + 1
end repeat
end tell -- to System Events
end resetFirstFolder
on resetSecondFolder(this_File) -- ALL saved in original name extensions
set file_to_store to ptdpsf & ":" & file_Name2 & "." & file_Extension
tell application "System Events"
set file_Extension to name extension of file this_File -- As you wrote that original files are PSD ones I don't understand the need for this instruction
set x to 1
repeat
if not (exists file file_to_store) then exit repeat
set maybe to file_Name2 & " " & x & "." & file_Extension
set file_to_rename to ptdpsf & ":" & maybe
if not (exists file file_to_rename) then
set name of file file_to_store to maybe
exit repeat
end if
set x to x + 1
end repeat
end tell -- to System Events
(*
-- Your code
try
tell application "Finder" to move file this_File to folder ptdpsf
on error
try
tell application "Finder" to move file 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
*)
(*
-- shorten one
try
tell application "Finder" to move file this_File to folder ptdpsf with replacing
on error errmsg
display dialog errmsg -- < write to ":Photoshop_Batch_Errors_Log.txt" here
end try
*)
(*
No longer use the Finder
*)
try
do shell script "mv -f " & quoted form of POSIX path of this_File & space & quoted form of POSIX path of ptdpsf
on error errmsg
display dialog errmsg -- < write to ":Photoshop_Batch_Errors_Log.txt" here
end try
end resetSecondFolder