PDA

View Full Version : AppleScript: Transfer tasks from THL (The Hit List) to OmniFocus


eatmytag
2009-08-28, 05:47 AM
I am currently using The Hit List (used OmniFocus, but then moved to Things, and then to THL).

However, I will be getting an iPhone soon and as THL does not as of yet have an iPhone app, I wanted to move back to OF (as Things does not quite work like I want it to).

THL does not export stuff, but it does support AppleScript, so I wrote a small script that creates new tasks in the OmniFocus Inbox using the current selected tasks in THL. Here is the script just in case somebody else needs to move.

You still have to do manual work, but not as much as you would have to. It would be possible to create a script that traverses the folder and list structure of THL and replicates it in OmniFocus, but this is Good Enough™ for me.

tell application "The Hit List"
activate
set tasklist to selection
set singleTask to true

if tasklist is not {} then
repeat with theTask in tasklist
set theStart to missing value
set theDue to missing value
set theOmniTask to missing value

set theTitle to the title of theTask
set theNotes to the notes of theTask
set theStart to the start date of theTask
set theDue to the due date of theTask

tell application "OmniFocus"
tell default document
set newTaskProps to {name:theTitle}
if theStart is not missing value then set newTaskProps to newTaskProps & {start date:theStart}
if theDue is not missing value then set newTaskProps to newTaskProps & {due date:theDue}
if theNotes is not missing value then set newTaskProps to newTaskProps & {note:theNotes}

set newTask to make new inbox task with properties newTaskProps
end tell
end tell
end repeat
end if
end tell

scottrych
2009-08-28, 06:20 PM
I am currently using The Hit List (used OmniFocus, but then moved to Things, and then to THL).

However, I will be getting an iPhone soon and as THL does not as of yet have an iPhone app, I wanted to move back to OF (as Things does not quite work like I want it to).

THL does not export stuff, but it does support AppleScript, so I wrote a small script that creates new tasks in the OmniFocus Inbox using the current selected tasks in THL. Here is the script just in case somebody else needs to move.

You still have to do manual work, but not as much as you would have to. It would be possible to create a script that traverses the folder and list structure of THL and replicates it in OmniFocus, but this is Good Enough™ for me.

tell application "The Hit List"
activate
set tasklist to selection
set singleTask to true

if tasklist is not {} then
repeat with theTask in tasklist
set theStart to missing value
set theDue to missing value
set theOmniTask to missing value

set theTitle to the title of theTask
set theNotes to the notes of theTask
set theStart to the start date of theTask
set theDue to the due date of theTask

tell application "OmniFocus"
tell default document
set newTaskProps to {name:theTitle}
if theStart is not missing value then set newTaskProps to newTaskProps & {start date:theStart}
if theDue is not missing value then set newTaskProps to newTaskProps & {due date:theDue}
if theNotes is not missing value then set newTaskProps to newTaskProps & {note:theNotes}

set newTask to make new inbox task with properties newTaskProps
end tell
end tell
end repeat
end if
end tell
That's awesome, where were you a week ago when I bailed on THL. ;)

Thanks,

Scott

eatmytag
2009-08-29, 02:18 AM
That's awesome, where were you a week ago when I bailed on THL. ;)

Thanks,

Scott

Why did you quit THL? I miss stuff from THL, any adaptation tips now that I am back to OF? I had tasks tagged in THL, how do you solve that in OF?

heidesw
2009-09-11, 05:25 PM
Alright, I'm not trying to stir stuff up but I do like using THL sometimes for shorter lists and haven't found an easy way to make a punch list in OF. My questions are can you make a shorter list in OF and how does one go about transferring from OF to THL. Does somebody know how to do either of these, and yes I will also post to the req. features section because overall I like OF better. Thanks for ANY help provided. Cheers.
Shawn

whpalmer4
2009-09-11, 09:53 PM
Perhaps for those of us (most?) who don't use The Hit List, you could give us a picture or something to illustrate what it is that you want.

eatmytag
2009-09-13, 07:31 AM
Alright, I'm not trying to stir stuff up but I do like using THL sometimes for shorter lists and haven't found an easy way to make a punch list in OF. My questions are can you make a shorter list in OF and how does one go about transferring from OF to THL. Does somebody know how to do either of these, and yes I will also post to the req. features section because overall I like OF better. Thanks for ANY help provided. Cheers.
Shawn

You can make as short lists as you want in OF.. maybe you are looking for the "single actions" option. Select a list, then open the inspector and change the list (project) type to "single action" (the shoe box).

BTW: A note on terminology. OF Projects = THL Lists. OF Action = THL Task. IMHO, THL terminology is more intuitive, but not as GTD.

eatmytag
2009-10-22, 06:20 AM
Ok, so I am moving back to THL. Just because I want to remember what the difference was, and because there might be a way for me sync THL and an IPhone.

So I made this script:

-- -------------------------------
-- This gets run from the tool bar
-- -------------------------------
on run
tell application "OmniFocus"
tell document window 1 of front document
set listTrees to selected trees of content
if (count of listTrees) = 0 then
try
display dialog "No tasks selected." & return
end try
else
my ExportTrees(listTrees)
end if
end tell
end tell

-- show the results in THL
activate application "The Hit List"
end run


-- ------------------------------------------------------------
-- Traverses the OmniFocus tree and create a task for each node
-- ------------------------------------------------------------
on ExportTrees(listTrees)

using terms from application "OmniFocus"
repeat with oTree in listTrees

-- intialize task string
set notes to ""
set tags to ""
set strName to ""
set isDone to false

-- get actual tree?
set oValue to value of oTree

-- Inbox does not have a name?
try
set strName to name of oValue
on error
set strName to "Inbox"
end try

-- get note if not Inbox
if strName ≠ "Inbox" then
set strNote to note of oValue
end if

-- get object class
set clValue to class of oValue

-- Get the context
set oContext to context of oValue
if oContext is not equal to missing value then
set tags to " @" & name of oContext & " "
end if

set dteStart to start date of oValue
set dteDue to due date of oValue
set estimate to estimated minutes of oValue

if flagged of oValue then
set tags to tags & " @flag" & " "
end if

if completed of oValue then
set isDone to true
end if

-- get any trees of the current tree if possible (sub trees)
set lstSubTrees to trees of oTree

-- if tree has sub trees
if (count of lstSubTrees) > 0 then
-- create task and move down tree
my createTHLTask(strName & tags, notes, dteStart, dteDue, estimate, isDone)
ExportTrees(lstSubTrees)
else
-- else, just create task
my createTHLTask(strName & tags, notes, dteStart, dteDue, estimate, isDone)
end if
end repeat
end using terms from
end ExportTrees


-- -------------------------------------
-- Create a task in the current THL list
-- -------------------------------------
on createTHLTask(theTitle, theNotes, theStartDate, theDuedate, theEstimate, theIsDone)
-- create the record to use to create a task
using terms from application "The Hit List"
set params to {title:theTitle}
if theDuedate is not missing value then
set params to params & {due date:theDuedate}
end if
if theStartDate is not missing value then
set params to params & {start date:theStartDate}
end if
if theNotes is not missing value then
set params to params & {notes:theNotes}
end if
if theEstimate is not missing value then
set params to params & {estimated time:theEstimate * 60}
end if
end using terms from

-- create the task in the current THL list
tell application "The Hit List"
set activeGroup to get selected group
tell activeGroup to make new task with properties params
end tell
end createTHLTask


It's based on this Omnifocus to Things script: http://coach.vaidabogdan.com/2009/09/convert-omnifocus-to-things.html

To use the script, copy it into ~/Library/Scripts/Applications/Omnifocus then restart OmniFocus and create a toolbar item from the script.

cheers!

robrecord
2009-11-01, 01:59 AM
Modified to allow note import:

-- -------------------------------
-- This gets run from the tool bar
-- -------------------------------
on run
tell application "OmniFocus"
tell document window 1 of front document
set listTrees to selected trees of content
if (count of listTrees) = 0 then
try
display dialog "No tasks selected." & return
end try
else
my ExportTrees(listTrees)
end if
end tell
end tell

-- show the results in THL
activate application "The Hit List"
end run


-- ------------------------------------------------------------
-- Traverses the OmniFocus tree and create a task for each node
-- ------------------------------------------------------------
on ExportTrees(listTrees)

using terms from application "OmniFocus"
repeat with oTree in listTrees

-- intialize task string
set notes to ""
set tags to ""
set strName to ""
set isDone to false

-- get actual tree?
set oValue to value of oTree

-- Inbox does not have a name?
try
set strName to name of oValue
on error
set strName to "Inbox"
end try

-- get note if not Inbox
-- if strName ≠ "Inbox" then
set strNote to note of oValue
-- end if

-- get object class
set clValue to class of oValue

-- Get the context
set oContext to context of oValue
if oContext is not equal to missing value then
set tags to " @" & name of oContext & " "
end if

set dteStart to start date of oValue
set dteDue to due date of oValue
set estimate to estimated minutes of oValue

if flagged of oValue then
set tags to tags & " @flag" & " "
end if

if completed of oValue then
set isDone to true
end if

-- get any trees of the current tree if possible (sub trees)
set lstSubTrees to trees of oTree

-- if tree has sub trees
if (count of lstSubTrees) > 0 then
-- create task and move down tree
my createTHLTask(strName & tags, strNote, dteStart, dteDue, estimate, isDone)
ExportTrees(lstSubTrees)
else
-- else, just create task
my createTHLTask(strName & tags, strNote, dteStart, dteDue, estimate, isDone)
end if
end repeat
end using terms from
end ExportTrees


-- -------------------------------------
-- Create a task in the current THL list
-- -------------------------------------
on createTHLTask(theTitle, theNotes, theStartDate, theDuedate, theEstimate, theIsDone)
-- create the record to use to create a task
using terms from application "The Hit List"
set params to {title:theTitle}
if theDuedate is not missing value then
set params to params & {due date:theDuedate}
end if
if theStartDate is not missing value then
set params to params & {start date:theStartDate}
end if
if theNotes is not missing value then
set params to params & {notes:theNotes}
end if
if theEstimate is not missing value then
set params to params & {estimated time:theEstimate * 60}
end if
end using terms from

-- create the task in the current THL list
tell application "The Hit List"
set activeGroup to get selected group
tell activeGroup to make new task with properties params
end tell
end createTHLTask

What was changed: Notes variable was named incorrectly; removed limitation of inbox items not passing on notes.