need help with compressor droplet watch folder script

I am trying to write a folder action to send video files through a compressor droplet when they are added to a folder. I found the script below on this forum. The only problem is that the whole script runs for every file added to the folder at once. I.E. if I drop two files in the folder it sends both files to my droplet twice, if there are three files, it sends all three through my droplet three times…

Is there something in the code below that could be modified to prevent this? I’m relatively new to scripting, so any help is greatly appreciated…

Applescript:

on adding folder items to thisFolder after receiving theItems
repeat with f in theItems
– wait for the item to be all there
set Was to 0
set isNow to 1
repeat while isNow ≠Was
set Was to size of (info for f)
delay 2 – longer if getting the item is slow
set isNow to size of (info for f)
end repeat
– Now do stuff to this f in thisFolder
end repeat – get next item f in thisFolder
end adding folder items to

figured it out. Original script looked like this:



on adding folder items to thisFolder after receiving theItems
	
	-- this is the standard intro for a folder action
	
	repeat with f in theItems
		
		-- wait for the item to be all there
		
		set Was to 0
		
		set isNow to 1
		
		repeat while isNow ≠ Was
			
			-- the basic idea is that the script loops until the file size is the same for more than 30 seconds. That means the file has finished copying.
			
			set Was to size of (info for f)
			
			-- this section is getting the file size of the video
			
			delay 30
			
			set isNow to size of (info for f)
			
			-- this section is sampling the file size 30 seconds later
			
		end repeat
		
		tell application "Finder"
			
			open theItems using application file "XDCam EX script.app" of folder "Desktop" of folder "Lars" of folder "Users" of startup disk
			
		end tell
		
	end repeat -- get next item f in thisFolder
	
end adding folder items to





then I moved the second “end repeat” to before the tell statement, and it worked:



on adding folder items to thisFolder after receiving theItems
	
	-- this is the standard intro for a folder action
	
	repeat with f in theItems
		
		-- wait for the item to be all there
		
		set Was to 0
		
		set isNow to 1
		
		repeat while isNow ≠ Was
			
			-- the basic idea is that the script loops until the file size is the same for more than 30 seconds. That means the file has finished copying.
			
			set Was to size of (info for f)
			
			-- this section is getting the file size of the video
			
			delay 30
			
			set isNow to size of (info for f)
			
			-- this section is sampling the file size 30 seconds later
			
		end repeat

            end repeat -- get next item f in thisFolder
		
		tell application "Finder"
			
			open theItems using application file "XDCam EX script.app" of folder "Desktop" of folder "Lars" of folder "Users" of startup disk
			
		end tell
	
end adding folder items to