65 lines
2.9 KiB
Markdown
65 lines
2.9 KiB
Markdown
---
|
||
title: Import Things tasks into Apple’s Reminders
|
||
author: James McDonald
|
||
type: post
|
||
date: 2012-12-08T13:36:46+00:00
|
||
url: /2012/12/import-things-tasks-into-apples-reminders/
|
||
categories:
|
||
- 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 Apple’s Reminders. Don’t ask – I’m a task list fetishist.
|
||
|
||
A neat trick you can do with Cultured Code’s <a href="http://culturedcode.com/things/" target="_blank">Things</a> 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:
|
||
|
||
<pre class="lang:default highlight:0 decode:true " title="Things export" >- Make lists of things
|
||
- Procrastinate (Try making scripts to manage lists of things)
|
||
</pre>
|
||
|
||
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.
|
||
|
||
<pre class="lang:applescript decode:true " title="Reminders Importer" >-- Reminders Importer
|
||
|
||
-- 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 McDonald: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
|
||
</pre>
|
||
|
||
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!
|