Folder Action issue

Under certain circumstances, my folder action doesn’t work properly:

on adding folder items to thisFolder after receiving addedItems
repeat with anItem in addedItems
tell application “Finder”
if name of file anItem contains “.ps” then
do shell script "pstopdf " & quoted form of POSIX path of anItem
end if
end tell
end repeat
end adding folder items to

This folder action should convert any postscript file dropped inside my folder to a PDF file. It does this job very well as long as while processing a couple of files, there are no new files dropped. As an example: I drop 5 postscript files and while processing the second one (I can see already the first generated PDF file) I drop 5 more files. At this moment, the folder action will “forget” about files 3, 4 and 5 from first round and will continue with second round dropped files. Those “forgotten” files will never be processed!

The only reason why my shown folder action script is using the “pstopdf” command is because it takes some time to process the files, so I can drop new ones while processing. You can replace that command with anything else that requires some time processing and will notice the same files “not processed”.

This is not an issue about how to convert postscript files to PDF, it is about folder actions not processing ALL files!
Any idea on how to avoid this kind of problems?

Interesting enough, there is a folder action located at Library:Scripts:Folder Action Scripts named “convert - PostScript to PDF.scpt” that works GREAT (It should, it comes from Apple :lol: )
It looks like my script is “loosing” the list of added items when new ones are dropped. :idea: I will check Apple’s folder action script…