tell application "Finder"
	try
		set the source_folder to (folder of the front window) as text
	on error -- no open folder windows
		set the source_folder to (path to desktop folder) as text
	end try
	set these_items to the selection
end tell
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
	set {file_name, file_ext} to splitExtension from the name of this_info
	set this_date to the modification date of this_info
	set formatted_date to (my dateFormat(this_date))
	set new_name to file_name & " (" & formatted_date & ")" & file_ext
	-- check to see if it's already there
	tell application "Finder"
		if (exists item (source_folder & new_name)) then
			display dialog new_name & " already exists."
		else
			set name of this_item to new_name
		end if
	end tell
end repeat


on dateFormat(theDate)
	set {year:y, day:d, time:t} to theDate
	copy theDate to b
	set b's month to January
	tell (y * 10000 + (b - 2500000 - theDate) div -2500000 * 100 + d) as string
		set date_string to text 1 thru 4 & "-" & text 5 thru 6 & "-" & text 7 thru 8
	end tell
	return date_string
end dateFormat

to splitExtension from file_name
	set dot to "."
	tell AppleScript
		set oT to text item delimiters
		set text item delimiters to dot
		if (count text items of file_name) > 1 then
			set out_name to (text items 1 through -2 of file_name) as string
			set ext to last text item of file_name
		else
			set out_name to file_name
			set ext to ""
		end if
		set text item delimiters to oT
		if ext is not "" then set ext to dot & ext
		return {out_name, ext}
	end tell
end splitExtension