Applescript Hotfolder

Hi there guys. I am trying to create a folder action to move files. Multiple users are dropping files to a watched folder with this script attached. What I need is for files to be moved to a second folder once they are done being copied over by the user. This gets tricky when multiple users are dropping files simultaneously though. If the script is busy moving one file/set of files and a second user drops a file, that second user’s file will get skipped.

Overview of process:
User drops to FOLDER A
File finishes copying to FOLDER A
File is is moved to FOLDER B

I pieced the below script together but cant seem to get it to work. By using filesize we can determine if the file has copied all the way over or not. Help?

property DELAY_TIME_SECONDS : 5 -- How long to wait between checking file size.

on adding folder items to thisFolder after receiving theItems
	repeat with f in theItems
		set oldSize to 0
		set newSize to -1
		-- When newSize equals oldSize, it means the copy is complete because the size hasn't changed.
		repeat while newSize is not equal to oldSize
			-- Get the file size.
			set oldSize to size of (info for f)
			delay DELAY_TIME_SECONDS
			-- Sample the size again after delay for comparison.
			set newSize to size of (info for f)
		end repeat
		
		-- HERE BEGINS THE MOVING SPECIFIC STUFF
		tell application "Finder"
			try
				set this_file to (item f of theItems)
				set processFolder to alias "Macintosh_HD:Users:Shared:SHACKATTACK:process"
				move this_file to processFolder
			end try
		end tell
		-- HERE ENDS THE MOVING SPECIFIC STUFF
		
	end repeat
end adding folder items to

What you are trying to do here will not solve the problem. On the contrary, your handler will become even slower, and will skip even more dragged files. I see the solution to this problem only in this: your handler should only create a list-queue (that is, only register new dragged files), or perform 1 simple task, and the rest processing should take place outside the handler.

Then the second handler should send a signal to the first handler, and that should remove the processed file from the queue. The first handler should be as fast as possible. Queue theory is not an easy task, and I’m not sure if it works out in AppleScript. But here the most important thing is this: your first handler should contain the code that is as fast and minimal in size as possible.

I recommend to break processing in the handler on steps, make multiple attached to hot folder scripts, and synchronize them to work correct together.

Do not attach to the hot folder script, which perform multiple tasks at once. Break on steps.