Folder action restarts when adding files while all ready processing

Hi,

Can anyone please help me?

I’ve written a Applescript folder action that processes some files. When adding some files, the script starts and all goes well. The processing of each files takes a few minutes, but all files are processed correctly.

However, when adding some new files to the dropfolder, while the folder action is all ready processing other files dropped a few minutes earlier, the process that is all ready running immediately aborts and the folder action is relaunched on the new files, leaving the old files for what they are…

Does anyone know how I can prevent the folder action being aborted when new files are dropped and placing the new files in “Hold”, until the previous files are processed?

Im running the latest version of os X 10.6.

Thanx

John

Hi,

When doing some test, this piece of code seems to work…

on adding folder items to this_folder after receiving added_items
– Disable all folder actions, so any new item added to folder while processing, has no effect !
tell application “System Events” to set folder actions enabled to false

    -- do long operation here

    -- If finished, the dropfolder should be emtpy and every added_item should be moved to the "done" folder
    
    -- If the folder contains files, they are new ones... Move them to a "Temp" folder
    tell application "Finder" to move entire contents of this_folder to folder TempFolder

    -- Enable back folder actions
    tell application "System Events" to set folder actions enabled to true

    -- Moving back all new items to the drop folder, triggering the folder action to restart on the new files
tell application "Finder"
	delay 3
	move entire contents of folder TempFolder to this_folder
end tell

end adding folder items to

This seems to work, but this script will never receive any awards as most professional script ever written or receive any beauty prices… :slight_smile:

Please share your insights…

Thanx

John