OK, here we go
Code:
-- property trig_folder : "Pueblo3:Users:erik.youngren:Desktop:Folder Action Scripts:" as alias
property source_folder : "PHOTO (ppsbsserver):CMYK_IN:" as alias
property dest_folder : "EDITORIAL (ppsbsserver):CCX_DO NOT DELETE" as alias
property error_folder : "PHOTO (ppsbsserver):ERROR:CMYK:" as alias
property batch_file : "Pueblo3:Users:erikyoungren:Library:Application Support:GraphicConverter:Actions:CMYK" as alias
on adding folder items to this_folder after receiving added_items
tell application "Play Sound"
play "Pueblo3:System:Library:Sounds:Glass.aiff"
end tell
growlAlert()
convertIt(source_folder)
end adding folder items to
on growlAlert()
tell application "GrowlHelperApp"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"Photo Server"}
-- Make a list of the notifications
-- that will be enabled by default.
-- Those not enabled by default can be enabled later
-- in the 'Applications' tab of the growl prefpane.
set the enabledNotificationsList to ¬
{"Photo Server"}
-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
register as application ¬
"Growl Photo Server" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Script Editor"
-- Send a Notification...
notify with name ¬
"Photo Server" title ¬
"Photo Server" description ¬
"Photos are now being processed" application name "Growl Photo Server"
end tell
end growlAlert
on convertIt(fda)
-- tell application "Finder"
-- open file "Trigger Photo.app" of trig_folder
-- end tell
tell application "Finder"
activate
set this_item to every file of fda
repeat with one_item in this_item
try
tell application "GraphicConverter"
convert file (one_item as file specification) using batch (batch_file as file specification) to folder (dest_folder as file specification)
end tell
on error the error_message number the error_number
set the error_text to "Error: " & the error_number & ". " & the error_message
-- the following line evokes the sub-routine to write the error into an error log created on the desktop
-- if the file "Script Error Log.txt" already exists, it will add one line to the log
my write_error_log(the error_text)
move it to error_folder with replacing
end try
end repeat
end tell
end convertIt
on write_error_log(this_error)
set the error_log to ((errorFolder) as text) & "Script Error Log.txt"
try
open for access file the error_log with write permission
write (this_error & return) to file the error_log starting at eof
close access file the error_log
on error
try
close access file the error_log
end try
end try
end write_error_log
Modify as you see fit. It's a Folder Action Script. First thing it does is play a sound (alerts me that the script has been triggered) and sends me a Growl notification.
Since this is a FAS I have my folders listed as properties so I only need to call the property and not the folder. This should easily convert to a droplet though if you want to do that. And you can eliminate the play sound and Growl notification too. The main part of the Applescript is after the Growl notification.
Note that I have GC set to batch process silently, meaning it does not show you that it's opening and processing files. You can set it the other way though if you like.
I would make ALL my preference settings to GC, then make my batch file. You want GC set up with the preferences you want to use before you process anything.
Lastly, note that there is a bug in GC. If GC crashes or you do not do the following (I will list it in a minute) any file that GC writes out will not have a filename extension at the end.
Every time you reopen GC you have to simply open the Batch process editing function and then open your batch process file. You don't need to do anything but open it, you can cancel everything and close the edit feature right after you open the batch process file. But, if you don't do that you will not get files with their extension.
Hope this helps.