Make your own backup program

I’m too cheap to spring for a .Mac account and haven’t had a decent backup program since System 7. But I still do backups. I wrote a “quick and dirty” droplet using DropStuff that archives my folders and saves them wherever I want them, then comments the original folders with “backed up on (date)”. I thought others might benefit from it:

(* the shortDate routine benefitted greatly by revision by Nigel Garvey *)

on open droppedItems
	set destination to choose folder with prompt "Where to save the archives?"
	with timeout of 1200 seconds
	-- set the timeout longer if you have really big folders
		try
			repeat with thisItem in droppedItems
				tell application "DropStuff" to stuff thisItem ¬
					into destination with ignore desktop files
			end repeat
		on error errMsg number errNum
			display dialog "Error " & errNum & ":" & ¬
				return & return & errMsg buttons {"Cancel"} ¬
				default button 1 with icon caution
		end try
	end timeout
	copy "backed up on " & shortDate(current date) to myComment
	repeat with thisItem in droppedItems
		tell application "Finder" to set the comment of thisItem to myComment
	end repeat
end open

to shortDate(theDate)
	-- Use month constants instead of strings.
	set monthList to {January, February, March, April, May, June, July, August, September, October, November, December}
	
	set mm to 1
	-- Extract the month constant from theDate only once, before the repeat.
	set theMonth to month of theDate
	-- Test positively rather than negatively, if possible. (Very esoteric, this one!)
	repeat until (theMonth = item mm of monthList)
		-- Use 'set' rather than 'copy', unless you really need to duplicate the data.
		set mm to mm + 1
	end repeat
	if (mm < 10) then set mm to "0" & mm
	
	set dd to day of theDate
	if (dd < 10) then set dd to "0" & dd
	
	-- Notice here that if either dd or mm is greater than 9,
	-- it'll still be an integer, not a string. An explicit coercion is
	-- needed below to ensure that a string is returned, not a list!
	
	set yy to text 3 thru 4 of ((year of (theDate)) as string)
	
	-- 'if second word of (date ("1/2/3" as string) as string) is "January" then'
	-- is only reliable on systems where the long date is in English, the weekday
	-- is included and comes first, and the year comes last. It's more internationally
	-- applicable and more efficient to use the month constant. But this still won't
	-- be right if the user's machine is configured for yyyymmdd short dates.
	if (month of (date ("1/2/3" as string)) is January) then
		-- dd and mm could be either strings or integers.
		-- Explicitly coerce the first one to string
		-- to ensure the desired concatenation result.
		return (mm as string) & "/" & dd & "/" & yy
	else
		return (dd as string) & "/" & mm & "/" & yy
	end if
end shortDate