Help with sorting misc. files via applescript

I am wanting the end result of this applescript to be where I can drag and drop a folder on it with miscellaneous files inside (.doc, .ppt, .xls, .pdf, .mp3, .jpeg, .jpg, .bmp, etc.) and for them to automatically sort into its appropriate location on the computer. Picture files would move to the user’s pictures folder, music would move to the user’s music folder, and document files would move to the user’s documents folder. This script needs to be universal to where it can work on an unlimited amount of computers. I’m somewhat new to applescript but I just can’t figure this one out on my own. I may be way off track, but here is what I’ve put together so far.

on adding folder items to this_folder after receiving added_items
	repeat with item_ in added_items
		tell application "Finder"
			set theFolder to path to documents folder from user domain
		end tell
		tell application "Finder"
			try
				if name extension of item_ is "doc" then
					move item_ to theFolder with replacing
				else
					if name extension of item_ is "txt" then
						move item_ to theFolder with replacing
					end if
				end if
			end try
		end tell
	end repeat
end adding folder items to

Hi,

this is an example for a droplet. Save the script as application bundle.
You can add further filter categories


property docExtensions : {"txt", "doc", "rtf"}
property picExtensions : {"jpg", "tif", "png"}

on open theseItems
	repeat with item_ in theseItems
		set Ex to name extension of (info for item_)
		tell application "Finder"
			if Ex is in docExtensions then
				move item_ to folder "Documents" of home
			else if Ex is in picExtensions then
				move item_ to folder "Pictures" of home
			end if
		end tell
	end repeat
end open


Thanks so much! It works beautifully. Here is a copy of the final script just in case anyone needs it.

property docExtensions : {"txt", "doc", "rtf", "docx", "log", "msg", "pages", "txt", "wpd", "wps", "csv", "pps", "ppt", "pptx", "vcf", "wks", "xls", "xlsx", "xml", "pdf", "htm", "html", "xhtml", "7z", "deb", "gz", "pkg", "rar", "sit", "sitx", "zip", "zipx"}
property picExtensions : {"jpg", "tif", "png", "pct", "bmp", "gif", "jpeg", "psd", "psp", "thm"}
property audioExtensions : {"aac", "aif", "m3u", "mid", "midi", "mp3", "mpa", "ra", "wav", "wma"}
property videoExtentions : {"3g2", "3gp", "asf", "asx", "avi", "flv", "mov", "mp4", "mpg", "rm", "swf", ".vob", "wmv"}
property winsysfilesExtentions : {"cab", "cpl", "cur", "dll", "dmp", "drv", "key", "lnk", "sys", "exe", "app", "bat", "cgi", "com", "pif", "vb", "ws", "db", "cfg", "ini", "prf", "bin", "tmp", "sav"}

on open theseItems
	repeat with item_ in theseItems
		set Ex to name extension of (info for item_)
		tell application "Finder"
			if Ex is in docExtensions then
				move item_ to folder "Documents" of home
			else if Ex is in picExtensions then
				move item_ to folder "Pictures" of home
			else if Ex is in audioExtensions then
				move item_ to folder "Music" of home
			else if Ex is in videoExtensions then
				move item_ to folder "Movies" of home
			end if
		end tell
	end repeat
end open

tell application "Finder"
	move winsysfilesExtentions to the trash
end tell