James McDonald

Import Things tasks into Apple’s Reminders

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 Apple’s Reminders. Don’t ask – I’m a task list fetishist.

A neat trick you can do with Cultured Code’s 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 there’s 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 I’d just written down.

Here’s the AppleScript code to accomplish this feat.

-- Reminders Importer
-- James McDonald <[email protected]>

-- 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"}
        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 ""
                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 I’ve 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, it’s this afternoon. Yay!


comments powered by Disqus