Skip to content

Instantly share code, notes, and snippets.

@mremond
Forked from matellis/things3-to-of3.applescript
Created September 19, 2018 09:37
Show Gist options
  • Save mremond/0ab75c30b3cb57a9ae76d4a347c9bbf7 to your computer and use it in GitHub Desktop.
Save mremond/0ab75c30b3cb57a9ae76d4a347c9bbf7 to your computer and use it in GitHub Desktop.
Script to import from Things 3 into Omnifocus 3
--------------------------------------------------
--------------------------------------------------
-- Import tasks from Things to OmniFocus
--------------------------------------------------
--------------------------------------------------
--
-- Script taken from: http://forums.omnigroup.com/showthread.php?t=14846&page=2
-- Added: creation date, due date, start date functionality
-- Empty your Things Trash first.
-- Note that this won't move over scheduled recurring tasks.
tell application "Things3"
-- Loop through ToDos in Things. Do Next, Scheduled, Someday, Inbox.
-- Note that Someday'd Projects don't get included.
-- After doing the above lists, move Someday projects to Next and change this to "of project "project name"".
repeat with aToDo in to dos of list "Upcoming"
-- Get title and notes of Things task
set theTitle to name of aToDo
set theNote to notes of aToDo
set theCreationDate to creation date of aToDo
set theDueDate to due date of aToDo
set theStartDate to activation date of aToDo
-- get dates
if (creation date of aToDo) is not missing value then
set theCreationDate to creation date of aToDo
else
set theCreationDate to today
end if
if (due date of aToDo) is not missing value then
set theDueDate to due date of aToDo
end if
if (activation date of aToDo) is not missing value then
set theStartDate to activation date of aToDo
end if
-- Get project name
if (project of aToDo) is not missing value then
set theProjectName to (name of project of aToDo)
else
set theProjectName to "No Project In Things"
end if
-- Get Contexts from tags
-- get all tags from one ToDo item...
set allTagNames to {}
copy (name of tags of aToDo) to allTagNames
-- ...and from the project...
if (project of aToDo) is not missing value then
copy (name of tags of project of aToDo) to the end of allTagNames
end if
-- Create a new task in OmniFocus
tell application "OmniFocus"
tell default document
repeat with theTag in allTagNames
set theTag to theTag as string
if not (theTag = "") then
if not (tag theTag exists) then
log "Created new tag '" & theTag & "'"
make new tag with properties {name:theTag}
end if
end if
end repeat
-- Set (or create new) project
if project theProjectName exists then
set theProject to project theProjectName
else
set theProject to make new project with properties {name:theProjectName}
end if
set testTag to tag "schedule"
-- Create new task
tell theProject
set newTask to make new task with properties {name:theTitle, note:theNote, creation date:theCreationDate}
if (theStartDate is not missing value) then set the defer date of newTask to theStartDate
if (theDueDate is not missing value) then set the due date of newTask to theDueDate
repeat with theTag in allTagNames
-- set theRealTag to tag theTag
-- log "theRealTag:" & (theRealTag as string)
-- set the tag of newTask to tag theTag
end repeat
end tell
end tell -- document
end tell -- OF application
end repeat -- Main loop
end tell -- Things application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment