Folder Action script for Copying files to multiple locations...

Try it, and give me some pointers…

When you bind it to a folder, it will ask for one or more targets after you drop your first item into it. Then it will duplicate the items to those folders. It remembers the targets, and puts Aliasses inside the “targets” folder in the hotfolder. You can add/remove aliasses (the target folders) to/from this folder manually.

It will delay for a minimum of five seconds per file after it is done copying (stable time).

Here it is:

on adding folder items to theFolder after receiving addedItems
	stable(addedItems) -- subroutine that waits for all the added items to become stable (by checking the docsize at 5 second intervals).
	
	tell application "Finder"
		set targets to null -- Check if the hotfolder is used for the first time, and act accordingly...
		try
			set targets to (folder "targets" of theFolder)
		end try
		if targets = null or the (count of every item in targets) = 0 then
			my firstrun(theFolder) -- subroutine that sets up the target folders, if they do not exist...
		end if
		my distribute(addedItems, theFolder) -- the subroutine that does the actual copying...
		
	end tell
end adding folder items to

-- Subroutines

on firstrun(theFolder)
	try
		tell application "Finder"
			if folder "targets" of theFolder exists then
				{}
			else
				make new folder in theFolder
				set the name of the result to "targets"
			end if
			set numberOfTargets to the text returned of (display dialog "How many target folders would you like?" default answer "1")
			repeat (numberOfTargets as number) times
				make alias to (choose folder)
				move the result to folder "targets" of theFolder
			end repeat
		end tell
	on error theError
		display dialog theError
	end try
end firstrun

on distribute(addedItems, theFolder)
	tell application "Finder"
		try
			set theAliasses to every item of folder "targets" of theFolder
			set targets to {}
			repeat with oneAlias in theAliasses
				set targets to targets & (the original item of (oneAlias) as string) as list
			end repeat
			repeat with theTarget in targets
				duplicate every item of addedItems to theTarget
			end repeat
		on error theError
			display dialog theError
		end try
	end tell
end distribute

on stable(addedItems)
	tell application "Finder"
		repeat with theItem in addedItems
			-- Mr Comment sez : "Aare u Copieink teh Fileh?"
			repeat
				try
					get info for theItem
					set sizethen to (size of the result)
				on error theError -- Stuff went wrong, master
					display dialog theError
					error number -128 -- break it off if stuff went wrong!
				end try
				delay 5
				get info for theItem
				set sizenow to (size of the result)
				if sizethen = sizenow then
					if sizenow = 0.0 then
						error number -128 -- break it off if stuff went wrong!
					end if
					exit repeat
				end if
			end repeat
		end repeat --Waiting for all files to become stable
		
	end tell
	
end stable