Skip to main content
Participant
September 24, 2008
Question

Please help -- CS3 applescript -- would gladly pay $100.

  • September 24, 2008
  • 13 replies
  • 2242 views
Hi, I've found myself in a situation where I urgently need a simple applescript to do a batch process in CS3. It's quite simple what we need and if there's anyone reading this who knows this stuff, I would gladly pay $100 for this simple Applescript.

We just need to run a single batch command in Adobe Photoshop CS3.

What we need to tell Photoshop to do is to run the "RainbowProcess" action. So what we're doing is the same as what you would get if you did a command on our computer of "File > Automate > Batch... and selected "Rainbow Process" as the action.

The source folder should be "Production Junction:Web2PrintPhotos", and it should process all files in all subfolders, and ignore any non-image files.

The settings we need are:
- File options dialogs and color profile warnings should be disabled/suppressed.

- Files should be saved and closed ("in place", i.e., replacing the source files).

- Include all subfolders.

- Destination should be "save and close", and action "save as" commands should be overriden.

- Errors should not be stopped for, but rather should be logged to file. That file should be "Production Junction:errors.txt".

Anyone up for it? I truly would gladly pay $100 for this simple Applescript.

I'm all about learning how to do this myself, I just find myself looking through that huge 237 page Photoshop CS3 applescript reference guide in the midst of a major major time deadline.
This topic has been closed for replies.

13 replies

Known Participant
March 5, 2009
as X has already suggested create a set of your own colo(u)r settings and switch to this. You can script this very easily as you just need the name string of whatever you've called it.

tell application "Adobe Photoshop CS2"
activate
-- Record current settings
set User_CS to color settings
-- Apply your settings
set color settings to "Marks Test"
end tell
--
(*do your processing here*)
--
tell application "Adobe Photoshop CS2"
-- Put back settings
set color settings to User_CS
end tell
--
(*or apply/convert profiles*)
--
tell application "Adobe Photoshop CS2"
activate
tell document 1
-- Apply a colour profile
if color profile name ≠ "Europe ISO Coated FOGRA27" then
set color profile name to "Europe ISO Coated FOGRA27"
end if
-- Convert to colour profile
if color profile name ≠ "U.S. Sheetfed Coated v2" then
convert to profile ¬
"U.S. Sheetfed Coated v2" intent absolute colorimetric ¬
with dithering without blackpoint compensation
end if
end tell
end tell
Participant
March 4, 2009
This is a great thread and I thought somebody here would be able to answer what I think is a pretty easy automator question. Like Guido, I have a process where I batch resize images through photoshop, and then rename and copy those images to multiple web servers using Automator.

My issue arises during the photoshop render portion of my automator actions. Some files prompt me when there is a color profile issue. When you batch through bridge you can turn of these warnings but I can't figure out how to do that in automator. Does anybody know any tricks around this?

Thanks!
Known Participant
March 4, 2009
judd_lamphere@adobeforums.com wrote:
> Some files prompt me when there is a color profile issue.

The simplest thing would be to create a Color Settings preset that has the
warnings turned off. Switch to that preset before running your Automator stuff.

-X
Participant
September 30, 2008
Thank you! I will give that a try ... I think it's going to help a lot ...
Known Participant
September 29, 2008
By default AppleScript has a built in time of 60 seconds to receive a response to an event. If something is taking longer than this you can alter an event or group of events by wrapping them in a time out block. It is difficult to say what may be causing this issue does the script still complete what its been asked? If you try running the script from Script Editor does the Event log tell you where its timing out? Like I said earlier this is the first time I've even looked at the batch command I almost always just use a standard repeat loop to process multiple files. I also try to keep clear of using actions where ever possible too as these are non conditional and require resources external to the script. An AppleScript time out would look like this:

with timeout of 300 seconds
-- do stuff here
end timeout

As well as AppleScript's standard suite of commands which are pretty good. 2 very nice things about AppleScript are the ability to "do shell script" which gives you access to some very powerful commands on the OS side. And Adobe's Apps will also allow you to do JavaScript. You should be able at automate just about any workflow you could imagine.
Wrapping JavaScript code for Automator would go like this:

set JavaScript to "The JavaScript code string"
--
tell application "Adobe Photoshop CS2"
activate
do javascript JavaScript ¬
show debugger on runtime error
end tell
Participant
September 26, 2008
Wow, thank you! I would be happy to send a donation to your favorite charity or something of the sort if you like ...

I just have one last question ... the script runs great (I changed the input_folder as you suggested) but after about 2 minutes I get a little pop-up message that says "AppleEvent Timed Out". The script keeps working in the background, meanwhile (it takes about 15 minuets to do all the photos), but the pop-up message has to be dismissed. Anyone have any idea what might be causing that?

Here's my current code in case that helps ...

-- Concatenate text strings for error text file location
set Error_File to "PhotoMac:Users:PhotoMac:Desktop:" & "Image Error Report.txt"
-- Make a text file to write error log to
my write_to_file("", Error_File, false)
-- Make the variable to the file an alias (as required by Photoshop)
-- coercion to alias can only be made with a file that already exists
set Error_File to Error_File as alias
-- Choose source of input & get all files
set Input_Folder to "Production Junction:Web2PrintPhotos:" as alias
-- Create a list of files coerced to aliases (as required by Photoshop)
tell application "Finder"
set File_List to (files of entire contents of Input_Folder) as alias list
end tell
--
tell application "Adobe Photoshop CS3"
activate
-- Set your required batch options
set Batch_Options to {class:batch options, destination:save and close, error file:Error_File, macintosh compatible:true, override open:false, override save:true, suppress open:true, suppressprofile:true, unix compatible:true, windows compatible:true}
-- Run batch command using the above paramitters
batch "RainbowProcess" from "Default Actions" from files File_List with options Batch_Options
end tell
--
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as string
set the open_target_file to open for access file target_file with write permission
if append_data is false then set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file

This stuff is so powerful, I'm curious about what kinds of workflows people have been coming up with ... I thought all my years of using XData in QuarkXPress were cool, but that was just scratching the surface ...

I'm hugely grateful for your help.

G.
Known Participant
September 26, 2008
Guido, where is the folder that you want hard wired? if local on you mac then you could do this your self by replacing the line:
"set Input_Folder to choose folder with prompt "Choose your top level folder?" without invisibles"
to something like
"set Input_Folder to (path to desktop folder as Unicode text) & "Some Folder:" as alias"
this creates a flexible path to the desktop and Concatenates the folder's name string to it.
You will of cause need to replace "Some Folder" with your folders name. This line will not compile as script if you have anything wrong.
Be careful to add the colon ":" at the end of the folders name this is to indicate that this is a folder. Any problems then post them back.
I could not work out why you needed AppleScript but then I don't use Automator in my workflows just script. Glad that it worked. I have a PayPal account but its only ever been used to pay out
Participant
September 26, 2008
Wow Mark, you did it! I plugged in my values and the script seems to work!!!!!!

I was able to record an action in Photoshop CS3 of the exact batch command that I need, so yes, a simple Applescript that ran that action is all I needed.

The only thing that is missing is ... how do you write in a "hardwired" Input_Folder statement (i.e., a fixed location) instead of having it do a prompt?

In case you all are wondering what I'm trying to accomplish: Basically, I need an applescript that I can import into an Automator workflow. The workflow includes a Transmit FTP download command, and the idea is that the applescript will handle the results of that, processing the downloaded images with this batch command action. The idea is to save the overall Automator workflow as an application, then run that as a weekly cron job using iCal. Does that make sense? That's why the batch command by itself isn't sufficient for my needs -- because, as far as I know, it can't be "called" by a remote program, except for Applescript or Javascript.

That's also why I need it without the prompt ... any suggestions about that would be really appreciated. Also, if you'd like that $100, please send me your paypal address if you have one, 'cause I meant what I said, since this helps me out a lot. I know that X helped too with the idea of what approach to take, so I'll leave it to you to work that out as appropriate etc. ....

Most importantly, thanks for nailing it ... I'm just getting started, hope to learn a lot more about scripting Photoshop and other CS3 apps, maybe I'll be posting solutions myself on here one of these days ...

Please let me know if you have thoughts about the non-prompt line, and thanks very much for taking the time ...

Sincerely,
Guido
Known Participant
September 25, 2008
Well, here is my first try at doing things using batch (which I don't like)

-- Concatenate text strings for error text file location
set Error_File to (path to desktop folder as Unicode text) & "Image Error Report.txt"
-- Make a text file to write error log to
my write_to_file("", Error_File, false)
-- Make the variable to the file an alias (as required by Photoshop)
-- coercion to alias can only be made with a file that already exists
set Error_File to Error_File as alias
-- Choose source of input & get all files
set Input_Folder to choose folder with prompt "Choose your top level folder?" without invisibles
-- Create a list of files coerced to aliases (as required by Photoshop)
tell application "Finder"
set File_List to (files of entire contents of Input_Folder) as alias list
end tell
--
tell application "Adobe Photoshop CS2"
activate
-- Set your required batch options
set Batch_Options to {class:batch options, destination:save and close, error file:Error_File, macintosh compatible:true, override open:true, override save:true, suppress open:true, suppressprofile:true, unix compatible:true, windows compatible:true}
-- Run batch command using the above paramitters
batch "Action 6" from "Marks Set" from files File_List with options Batch_Options
end tell
--
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as string
set the open_target_file to open for access file target_file with write permission
if append_data is false then set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
Known Participant
September 25, 2008
From the OP's request I can't see anything that would require the need of script? or am I over looking the obvious? (haven't used actions in a while.) Record an Action then run batch with said Action? Bar a couple of the options (none the OP requested) batch offers nothing more than a loop which I can do anyhow using a repeat statement. The only conditional I could see is which files to process if the folders contain undesirables.
Known Participant
September 24, 2008
Batch looks easy enough although I've never used it before. Most of what it offers can be done via script any how. The biggest problem I see is "ignore any non-image files" what do you consider these to be EPS & PDF can be image, vector or both? do you have lists of file types you do & don't want to be processed? Also not quite sure why you need a script to do this? If X can't help you then post back and I will try.
Known Participant
September 24, 2008
Mark_Larsen@adobeforums.com wrote:
> If X can't help you then post back and I will try.

Eh, my thought was that you record an action that actually does the batch, then
call that action from AS. If that doesn't work for some reason, I've probably
got something laying around (like xbatch) that may do the trick.

-X
--
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com