Can someone please post a script snippet example that uses Photoshop’s batch command.
I have been trying all day, but can not figure out what I am doing wrong. I got it to work if I pass in one file, but I would like to send in a folder or list of files and have the batch process work on all of them.
There is not a reason - I was doing that before, but it seemed very slow. I was hoping that the batch method would be much faster. It seemed a little faster manually doing it so I was trying to test it.
Thanks
I got this to work
set thePath to (path to desktop as string) & "new script:test:"
set thefile to thePath & "AMarin-10 copy.jpg"
tell application "Adobe Photoshop CS2"
activate
set myOptions to {destination:save and close}
batch "Proofs" from files thefile from "eMotion Actions" with options myOptions
end tell
But this did not work. Said it could not find the file.
set thePath to (path to desktop as string) & "new script:test:"
set theFileList to (list folder thePath without invisibles)
tell application "Adobe Photoshop CS2"
activate
set myOptions to {destination:save and close}
batch "Proofs" from files theFileList from "eMotion Actions" with options myOptions
end tell
set thePath to (path to desktop as string) & "new script:test:"
set theFileList to (list folder thePath without invisibles)
List folder gives the folder contents by name:
To process the files you need paths to the files:
set thePath to (path to desktop as string) & "DeskCleanup:"
tell application "Finder" to set theFileList to files of folder thePath
Now the files are in a list ready for processing:
set thePath to (path to desktop as string) & "new script:test:"
tell application "Finder" to set theFileList to files of folder thePath
tell application "Adobe Photoshop CS2"
activate
set myOptions to {destination:save and close}
batch "Proofs" from files theFileList from "eMotion Actions" with options myOptions
end tell
I apologize for being a pain or an idiot whichever way you see it, but this is the error I get when I try your code.
Can’t make «class docf» “3 copy 1.jpg” of «class cfol» “Test 2” of «class cfol» “New Script” of «class cfol» “Desktop” of «class cfol» “tracy” of «class cfol» “Users” of «class sdsk» of application “Finder” into the expected type.
When I go into PS CS2 and select the batch process manually on that folder it works just fine.
here is some code that does the trick for me in CS2, hope this helps !
/ Stefan
-- This droplet processes files dropped onto the applet
on open these_items
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items)
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) then
process_item(this_item)
end if
end repeat
end open
-- this sub-routine processes folders
on process_folder(this_folder)
set these_items to list folder this_folder without invisibles
repeat with i from 1 to the count of these_items
set this_item to alias ((this_folder as text) & (item i of these_items))
set the item_info to info for this_item
if folder of the item_info is true then
process_folder(this_item)
else if (alias of the item_info is false) then
process_item(this_item)
end if
end repeat
end process_folder
-- this sub-routine processes files
on process_item(this_item)
tell application "Finder"
if not (exists folder "preview_jpegs" of desktop) then
make new folder at desktop with properties {name:"preview_jpegs"}
end if
end tell
tell application "Adobe Photoshop CS2"
set myOptions to {class:JPEG save options, embed color profile:true, format options:standard, matte:none, quality:9}
open this_item showing dialogs never
set docRef to the current document
--if you want an action done, you can add it here using the action name and the set name:
do action "invert" from "testscripts"
-- convert docRef to profile "sRGB IEC61966-2.1" intent perceptual
-- resize image docRef resolution 96 resample method bicubic
-- Save the shit
set docName to name of docRef
set dPath to ("" & (path to desktop) & "preview_jpegs:")
save current document in file (dPath & docName) as JPEG with options myOptions appending lowercase extension with copying
close current document without saving
end tell
end process_item
PS is being passed file references it can’t understand. What is happening is the Finder is getting a Finder native reference to each file of the target folder. These are in the form:
document file "3 copy 1.jpg" of folder "Test 2" of folder "New Script" of folder "Desktop" of folder "tracy" of folder "Users" of startup disk of application "Finder"
While PS expects alias references, i.e. alias “HD:Users:username:Desktop:file.jpg”. So you just need to get an alias list. Unfortunately, as far as I know, Finder still can’t coerce one item into an alias list so you need to wrap the attempt to get the alias list in a try block and accommodate one item if it errors. Like so:
on aliasListForFolder(theFolder)
set theFolder to theFolder as text
tell application "Finder"
try
set aliasList to every document file of folder theFolder as alias list
on error
set aliasList to every document file of folder theFolder as alias as list
end try
end tell
return aliasList
end aliasListForFolder
So instead of the line: ‘tell application “Finder” to set theFileList to files of folder thePath’; use:
set theFileList to aliasListForFolder(thePath)
I have no idea if this will actually solve your problem since I don’t have CS2 and CS doesn’t have the batch command but I suspect this is the problem.