Help with an open new items applescript

I am new to applescript and am trying to re-create a folder action that I had cobbled together once that will will be attached to the desktop and when I download a torrent file to the desktop it will open the file with the default application, delay 15 seconds, and then move the file to the torrent file to the trash. I am forgetting something and cannot make it work again. Here is the script that I have now.

on adding folder items to this_folder after receiving added_items
tell application “Finder”
if name extension of added_file is “.torrent” then
open added_items
delay 15
move added_items to trash
end if
end tell
end adding folder items to

Any suggestions? Thanks.

Model: 24" iMac
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Try something like this, LuckBox:

on adding folder items to this_folder after receiving added_items
	tell application "Finder" to repeat with this_item in added_items
		if name extension of this_item is "torrent" then
			open this_item
			delay 15
			delete this_item
		end if
	end repeat
end adding folder items to

That works. Thanks. But I don’t understand why. What is it repeating?

When a folder action is performed on a folder that has an attached Folder Action script, the Folder Actions architecture executes the attached script, passing to it appropriate information about the folder and the items added to or removed from it.

So when items are added to a folder, the value of the variable this_folder* will be a reference, in alias format, to the attached folder. The variable added_items* will contain a list of alias reference(s) to the item(s) placed in the attached folder.

So even if only one item is added to the attached folder, it will be in the form of a single-item list. (Always using a list means that, if required, several items may be added at a time.) To perform any actions on each added item, we need to iterate through the list (albeit only once, in the case of a single-item list).

To iterate through a list, we use a repeat loop. In this particular form of repeat loop, the variable this_item* represents a reference to the current item in the added_items* list.

(* Or whatever you may decide to call each variable.)