I have a setup where a customer triggers ink-jet print-outs via a web site. The web site curls the file to a folder on an iMac at the customer’s office where the printer is located. That’s all fine and dandy.
I had to implement an Automator script to perform a chmod and a chown on the incoming files because the printer RIP for whatever reason would reject the files if the file owner was anything other the account that the RIP was running on. I tried to implement this as a do shell script in Applescript, but for whatever reason, the script wouldn’t run when files drop into the folder. So, as a workaround, I used Automator for that part of it.
Since this script was hijacking the files before they were completely uploaded, I implemented a file stabilization script that I found here on Macscripter.
on adding folder items to thisFolder after receiving addedItems
stable(addedItems)
tell application "Finder"
set Folder1 to ("Macintosh HD:Users:epson4800:Applications:ColorBurst RIP 4.1:Upload")
set Folder2 to ("Macintosh HD:Users:epson4800:Applications:ColorBurst RIP 4.1:Process_Upload")
move every file of folder Folder1 to folder Folder2
end tell
end adding folder items to
on stable(addedItems)
tell application "Finder"
repeat with theItem in addedItems
repeat
try
get info for theItem
set sizethen to (size of the result)
on error theError
display dialog theError
error number -128
end try
delay 5
get info for theItem
set sizenow to (size of the result)
if sizethen = sizenow then
if sizenow = 0.0 then
error number -128
end if
exit repeat
end if
end repeat
end repeat
end tell
end stable
After this script is performed, files pass to the “Process Upload” folder where this script is performed. Standard folder action script from Automator.
on adding folder items to this_folder after receiving added_items
tell application "Macintosh HD:Users:epson4800:Library:Workflows:Applications:Folder Actions:Upload_Script.app"
open added_items
end tell
end adding folder items to
The Automator script “Upload_Script.app” does the following:
1] sudo chmod 777 /Applications/ColorBurst*/Process_Upload/*
2] sudo chown epson4800 /Applications/ColorBurst*/Process_Upload/*
3] Get Specified Finder Items
/Applications/ColorBurst*/Process_Upload/
4] Get Folder Contents
5] Move Finder Items
/Applications/ColorBurst*/Hot_Folder/
All of these bits work exactly as I want… IF only one file is sent at a time. When several are sent within a short period of time, the first script will process the files and send them to the Process_Upload folder, where they’ll sit until someone moves them.
Am I missing something obvious here?
Thanks in advance.