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 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 files of folder ptdpp as alias list
end tell
say (count of PhotoshopFiles)
delay 4
repeat with this_File in PhotoshopFiles
tell application "Finder"
set file_Name to name of this_File
set file_Extension to "psd" --default Save name extension of this_File
set file_Name2 to characters 1 through -((count of file_Extension) + 2) of file_Name as text
display dialog file_Extension
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 -- Finder
tell application "Adobe Photoshop CS6"
activate -- is it really useful ?
open this_File
--set display dialogs to never
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
end tell -- Photoshop
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
end try
end try
end tell -- Finder
end repeat
on error errmsg
display dialog errmsg
end try
end adding folder items to
I'm puzzled by a detail.
If you know that the original files are PSDs, why are you rebuilding the name with long instructions ?
would be sufficient.
If it exists, in the folder ptdpsf, a file with the name of the new file to add, you rename the existing file.
From my point of view, it would be better to change the name of the added file.