Files
blog/content/posts/2012-12-08-import-things-tasks-into-apples-reminders.md
T
James McDonald 96eedb5095 Import
2018-01-09 20:39:32 +01:00

2.8 KiB
Raw Blame History

title, author, type, date, url, dsq_thread_id, categories
title author type date url dsq_thread_id categories
Import Things tasks into Apples Reminders james post 2012-12-08T13:36:46+00:00 /2012/12/import-things-tasks-into-apples-reminders/
964365161
Apple
Hacks

OK, so I was making a list of things to do today, but then I decided that having created them in Things, I wanted to move them to Apples Reminders. Dont ask Im a task list fetishist.

A neat trick you can do with Cultured Codes Things is to select a bunch of tasks and drag them to a text editor, which will create one line per task with any note appended in brackets. Looks sort of like this:

- Make lists of things
- Procrastinate (Try making scripts to manage lists of things)

This is all very well, but theres no simple way to get that list into Reminders without copying and pasting the relevant bits individually. That sounded boring, so instead I learned enough AppleScript to do it automatically. It probably took more time, but it was definitely more amusing. Anyway, it was that or complete the bunch of tasks Id just written down.

Heres the AppleScript code to accomplish this feat.

-- Reminders Importer
-- James McDonald <james@jamesmcdonald.com>

-- Imports a text file into Reminders as one task per line.
-- Creates a task list called "Import". Strips off " -" at the start and puts bracketed text into the body (note) of the task. This is the format you get by dragging from Things to a text editor.

tell application "Reminders"
	if not (list "Import" exists) then
		make list with properties {name:"Import"}
	else
		tell list "Import" to delete reminders
	end if
end tell

tell application "Reminders"
	repeat with l in paragraphs of (read file "Users:james:Documents:tasks.txt")
		if length of l is not 0 then
			if l starts with "- " then
				set l to characters 3 through end of l as text
			end if
			
			if l contains "(" then
				set AppleScript's text item delimiters to "("
				set b to text item 2 of l
				set l to text item 1 of l
				set AppleScript's text item delimiters to ")"
				set b to text item 1 of b
				set AppleScript's text item delimiters to ""
			else
				set b to "" as text
			end if
			tell list "Import"
				make reminder with properties {name:l, body:b}
			end tell
		end if
	end repeat
end tell

Yes, I know. AppleScript is weird.

So, now that Ive written the blog post about the script to migrate to one task manager from another the list of tasks I made of things to do this morning, its this afternoon. Yay!