File logjam in folder configured with Folder Actions, Automator.

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.

Sounds to me like there’s a bottle-neck being created by AppleScript and Automator. Either one action is timing out waiting for the other one, or the Automator script can’t execute because the AS engine is tied up with the AppleScript. I would try combining the functions of the Automator script into the AppleScript. You can change the file owner, group, and privileges using AppleScript, but I realize that the file owner can’t be changed unless you unlock the file permissions (with a password) first.

Will the RIP accept the file if the GROUP id is set to the same group as the RIP owner account? I don’t know what you’ve tried, but I’d try that, if you haven’t already.

The other option is to have the script run on the RIP owner account and take possession of the files that way.

If all else fails, get a crontab utility. Cron is the unix daemon that runs jobs when specified (every minute, every hour, every 2 hours, etc.) and write a shell script that takes possession of every file in the folder at a given interval (and move them if needed). You can write your own crontab file, but the format is a bit arcane (bordering on voodoo) and a crontab utility will make your life much easier.