Skip to content

Instantly share code, notes, and snippets.

@pdxmph
Created November 16, 2014 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdxmph/91152d0c3622725b3486 to your computer and use it in GitHub Desktop.
Save pdxmph/91152d0c3622725b3486 to your computer and use it in GitHub Desktop.
Convert all your Things projects to org mode projects and todos. Understands tags (converts to org-mode-style colon-delimited lists), due dates (converts to deadlines), status (converts "open" to "todo", "completed" to "DONE" and "canceled" to "CANCELED")
tell application "Things"
set myOrgOutput to ""
repeat with theProject in projects
set myName to the name of theProject & return
set myTasks to the to dos of theProject
set myOrgOutput to myOrgOutput & return & return & "* " & myName
repeat with myTodo in myTasks
set myDueDate to the due date of myTodo
set myToDoName to the name of myTodo
set myTags to the tag names of myTodo
if myTags is not "" then
set myTagList to my make_taglist(myTags)
else
set myTagList to ""
end if
if status of myTodo is open then
set myStatus to "TODO"
else if status of myTodo is completed then
set myStatus to "DONE"
else if status of myTodo is canceled then
set myStatus to "CANCELED"
end if
set myOrgOutput to myOrgOutput & return & "** " & myStatus & " " & myToDoName & " " & myTagList
if myDueDate is not missing value then
set theDeadline to my make_deadline(myDueDate)
set myOrgOutput to myOrgOutput & return & theDeadline & return
end if
end repeat
end repeat
end tell
on make_taglist(tags)
set myTags to do shell script "echo '" & tags & "'|sed s/,\\ /:/g"
return tab & tab & ":" & myTags & ":"
end make_taglist
on make_deadline(myDueDate)
-- arg. Mac's `date` isn't as good as GNU's `date`.
set myDeadline to do shell script "ruby -rDate -e \"puts Date.parse('" & myDueDate & "').strftime('%Y-%m-%d %a')\""
return "DEADLINE: <" & myDeadline & ">"
end make_deadline
return myOrgOutput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment