Today's To-Dos from iCal Events

Using AppleScript and the Automator application that ships with OS X, you can set up your computer to automatically copy information for the current day's events from iCal into Things. Here's how (in OS X 10.5.7, at least):

  1. Open the Automator application and create a new Custom workflow.
  2. Select "Find iCal Items" in the Actions list and drag it to the empty pane on the right.
  3. Set options for the Action:
      Find: Events
      Whose: Start date , today
    You can set additional conditions, such as a particular calendar, by clicking the "+" button on the right. You can also drag additional "Find iCal Items" actions below to get multiple sets of events (events must match at least one set of criteria to be included).
  4. From the Actions list, drag "Run AppleScript" and drop it below your "Find iCal Items" action(s).
  5. Paste the code below into the text box for the "Run AppleScript" action. It loops through the day's events, for each one adding new To Do in Today with the event's title, start time, location, and description/URL.
  6. Click "Run" in the upper right-hand corner of Automator. It should execute the workflow without any errors, adding to Things new To Dos for any events in your calendar meeting the criteria you specified.
  7. To have this workflow execute on a daily basis, use File > Save as Plug-in..., specify a name for the workflow, and choose iCal Alarm below. In iCal you can specify that the event should occur every day at a particular time (if your computer is asleep at that time, it will execute as soon as you wake it up).
on run {input, parameters}
  using terms from application "iCal"
	repeat with i from 1 to number of items of input
		set evt to item i of input
		set evtDateTime to start date of evt
		set h to hours of evtDateTime
		set m to minutes of evtDateTime
		set evtTime to (h as string) & ":" & (m as string)
		set t to (summary of evt)
		set d to ""
		if exists (url of evt) then
			set urlString to ((url of evt) as string)
			set d to d & "[url=" & urlString & "]" & urlString & "[/url]" & return & return
		end if
		if exists (description of evt) then
			set d to d & ((description of evt) as string)
		end if
		tell application "Things"
			-- adding to dos in lists
			set props to {name:t, notes:d, due date:evtDateTime, tag names:"Events"}
			make new to do with properties props at beginning of list "Today"
			set toDoToSchedule to first to do of list "Today"
			schedule toDoToSchedule for (evtDateTime)
		end tell
	end repeat
   end using terms from
return input
end run