help with printing script?

Hello scripters,

I employ a folder action script on a folder in which PDFs get produced to (OUT folder of DISTILLER setup) I currently use the lpr -P shell command in order to print the items, which works pretty well so far. However, if the OUT folder gets busy, and items are added before previous ones complete printing, then erratic behavior occurs. Either some pages don’t get printed at all, or some pages get printed multiple times, or any mixture of that behavior really. The script does a rm shell command to delete the files after they are printed (in theory) thereby keeping the folder clean, and avoiding duplicate printing of the same file, but things get hairy when many files hit the Distiller/IN queue. Is there a way to amend my script such that no file gets left unprinted, and my files are not deleted from the directory before they are printed? Here is the code so far:

on adding folder items to this_folder after receiving these_items
	do shell script "lpr -P leelu_lpr /Users/admin/Desktop/DISTILL/Out/*"
	do shell script "rm /Users/admin/Desktop/DISTILL/Out/*"
end adding folder items to

Thanks in advance for your help,
Andy-

Hey there.

I’ve been using ktam’s code that you can find here:

http://scriptbuilders.net/files/folderactionreplacement1.0.0.html

to do something similar. So far, it has been pretty bulletproof but if I remember correctly, you might need to accomodate the removal of processed files from the file list. Otherwise, it will ignore files with duplicate names.

-N