Log Today List (AppleScript)

During a time that things got really busy at work, I felt like I was losing track of my tasks - too many things were being rolled from one day to the next. So, I wrote this to output my current Today list and the count of items in the Inbox to a file, so I could get an idea how my list was growing throughout the day. I put it in a cronjob to run every fifteen minutes throughout the day. The instructions for that are below the code.

You must make one change to this script in order to use it: replace username with your own username in the line that defines the path to write to.

tell application "Things"
	-- Include date in the filename.  
	-- Filename will be ThingsToday.2009June5.txt
	set {year:y, month:m, day:d} to (current date)
	set fileName to "ThingsToday." & y & m & d & ".txt"
	
	-- Set the path.  You should replace 'username' with your actual 
	-- username, and change the path as you please 
	set pathName to "Macintosh HD:Users:username:Desktop:" & fileName
	
	set fullReport to ""
	
	-- To number the lines in the output
	set itemCount to 0
	
	repeat with aToDo in to dos of list "Today"
		set itemCount to itemCount + 1
		
		-- Include Project or Area name before item name
		if (project of aToDo) is not missing value then
			set todoDataRow to (itemCount as text) & ". " & ¬
				(name of project of aToDo) & ": " & ¬
				(name of aToDo) & tab
		else if (area of aToDo) is not missing value then
			set todoDataRow to (itemCount as text) & ". " & ¬
				(name of area of aToDo) & ": " & ¬
				(name of aToDo) & tab
		else
			set todoDataRow to (itemCount as text) & ". " & ¬
				(name of aToDo) & tab
		end if
		
		-- Create an empty list for tags
		set allTags to {}
		
		-- Get all tags on the todo item
		set todoTags to tags of aToDo
		repeat with aTag in todoTags
			copy (name of aTag) to the end of allTags
		end repeat
		
		-- Get all tags on the project, if there is one
		if (project of aToDo) is not missing value then
			set projTags to tags of (project of aToDo)
			repeat with aTag in projTags
				copy (name of aTag) to the end of allTags
			end repeat
		end if
		
		-- Get all tags on the area, if there is one
		if (area of aToDo) is not missing value then
			set areaTags to tags of (area of aToDo)
			repeat with aTag in areaTags
				copy (name of aTag) to the end of allTags
			end repeat
		end if
		
		-- Combine the tags into a comma-delimited list
		if allTags is not missing value then
			set AppleScript's text item delimiters to {", "}
			set todoDataRow to todoDataRow & ¬
				"(" & (allTags as text) & ")"
		end if
		
		set fullReport to fullReport & (todoDataRow & return as string)
	end repeat
	
	-- Get the count of inbox items
	set inboxItems to count of (to dos of list "Inbox")
	
	-- Compile the contects of the output for this run
	-- Include full date and time, and counts of items in Today and Inbox
	set fullReport to (((the current date) as string) & ¬
		(tab as string) & ¬
		(tab as string) & ¬
		(itemCount as string) & " items in Today, " & ¬
		(inboxItems as string) & " items in Inbox" & ¬
		return as string) & fullReport & return as string
	
	-- Open and write to the ouput file
	set outputFile to open for access (pathName as string) with write permission
	write (fullReport & return as string) to outputFile starting at eof
	close access outputFile
end tell

To create a cronjob, open Terminal and edit your crontab: crontab -e

Then paste this into the crontab. Change the path if you put the script somewhere else:

00,15,30,45 * * * * osascript /Library/Scripts/Things/LogCurrentTodayList.scpt > /dev/null