Using applescript to assign a folder action.

I am trying to set up a recursive folder action so that sub folders trigger an action as well as the main folder. The action of the main folder is an rsync used to mirror local content with a remote server. The content will have many levels of subdirectories, so I need a change in any subdirectory to trigger the folder action.

My current plan is that with every item added, it will check to see if it is a folder. If it is a folder, it will then assign a folder action script to that sub folder. I have my primary folder action working which calls my rsync mirroring shell script. As well I have the “adding folder items” working where it loops through the items and tests if the item is a folder.

The major piece I am not missing is the “assign folder action” function.

I am hoping to end up with something like the following :

on adding folder items to this_folder after receiving these_items
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items as alias)
		set this_info to (info for this_item)
		if folder of this_info then
			-- the next line is fake code
			set property folder action of this_item to "rsync-mirror.scpt"
		end if
	end repeat
end adding folder items to

Thanks for the help. If anybody know that this is NOT possibly, please post that. Knowing I cannot do something sometimes is as good as knowing how to do something.

From our FAQ:
http://bbs.applescript.net/viewtopic.php?id=14375