For a long time now, I’ve been trying to figure out the best way to get stuff into my todo list on my Mac from my Android phone. I should say that I belong to the crazy group that uses OmniFocus, which is obviously a Mac app. They have wonderful iPhone and iPad apps, but I don’t have an iPhone. Sure I could carry an iPod touch around with me everywhere I go and for the most part I do, but my HTC Hero is with me 24/7.
This may not be obvious to everyone, but the best todo list app for Android is Todo.txt Touch by Gina Trapani. This thing almost made me drop OmniFocus, but I really like what I’ve got going in OmniFocus so instead I’m using Todo.txt Touch as input.
I’ve written an AppleScript that will look at my todo.txt file stored in my Dropbox and send everything over to OminFocus:
tell application "Finder"
-- readFile
set TodoTXT to "<Path to todo.txt>"
set foo to (open for access TodoTXT with write permission)
set txt to (read foo for (get eof foo))
set eof foo to 0
close access foo
set Names to paragraphs of txt
repeat with nextLine in Names
if length of nextLine is greater than 0 then
tell application "OmniFocus"
set theDoc to first document
tell theDoc
make new inbox task with properties {name:nextLine}
end tell
end tell
end if
end repeat
end tell
Beware, this is my first iteration of this script. That doesn’t mean I’m promising future versions. I’m only using the Android app as input at this point. It will import all of your todos to the inbox and then blank the file.
Running it
First, Hazel is setup to watch the folder in my Dropbox with a rule that watches for the Created Date to be the same as the Modified Date. This basically means that the file is brand new. It might not be obvious at first why this works. Basically, when the todo.txt file syncs from Dropbox it is replaced with a new version, thus creating a new file in place of the one that was there. When the script then goes and updates the file, either by blanking it or, maybe in the future, updating it with todos from Omnifocus, it is modified locally and not recreated so the two different dates would be different.
The other way I can run the script is from within OmniFocus itself. The script lives in ~/Library/Scripts/Applications/OmniFocus/
, which let’s you add it while customizing the menu.
Feedback
If you find this useful, let me know. If you go on to modify it and make it even more useful than it already is, I’d love to hear about that too.
Update
After David Sparks linked here on his MacSparky blog, one user suggested a shorter version of the script:
set p to "<Path to todo.txt>"
set l to paragraphs of (do shell script "grep . " & p)
do shell script ">" & p
tell app "OmniFocus" to tell document 1
repeat with v in l
make new inbox task with properties {name:v}
end repeat
end tell
Thanks for that and thanks to David for linking here.
Thank you for this — I'm installing it now. My biggest frustration now is a non-kludgy way of entering tasks into OF from my Android – this might just do the trick…
Josh, I'm a developer looking to do the opposite of what you have here. I used OmniFocus for years and had it integrated with iPhone. Then I switched to Android and started a nearly two year search for something as good as OF. I never found it. I moved from one app to another finally landing on Todo.txt and Todo.txt Touch. Being a Mac guy, a developer, and a huge Terminal user I thought I had found heaven. But a few months in I realized how much I missed an interface like OF and things like quick entry.
I started looking around for something to replace Todo.txt and tried Wunderlist, Taskpaper, and a few others. I recently found Conqu, which is pretty new and actually built by some developer friends of mine. It's nice because it's cross platform (uses Adobe AIR) and works on just about everything. It's new enough though that there are quite a few missing features that I really need: reporting, recurring tasks, and more.
I'm now back to using OF and looking for a way to export tasks out of OF into a plaintext file (one line per task). I found an AppleScript that is a nice start, taking the Taskpaper export file and removing some bits of text like due dates. I want to get this process refined to a nice, neat, Todo.txt simplified file stored on Dropbox. This will let me use OF on the Mac and Todo.txt Touch on Android for basic read only task views while on the go.
If you've got something started along these lines, or you are interested in working on this, I'd love to talk.
The original plan was to start working on something like this, so I could go from todo.txt to OF and back, but I never got around to it. Now, I’m back using Things, but if you get something working I’d love to know about it. What I’ve posted here is all I’ve got.
Hi I'm trying to install this but can't figure it out.
Make sure you fill in the path to your todo.txt in the correct location. You should just be able to paste this into the apple script editor and go from there. I think you can drag the .scpt file into the toolbar in omnifocus, but it's been awhile so I can't say for sure.
Hey Josh! Thanks got it working!
Nice solution. Any idea how to make this work with accented characters?
Great tip!
I had some issues with duplicate tasks, and didn’t like the idea of marking items completed before I was sure that Hazel ran the script on the todo.txt file.
I modified the script to this:
set p to “”
set l to paragraphs of (do shell script “grep . ” & p)
tell application “OmniFocus” to tell document 1
repeat with v in l
make new inbox task with properties {name:v}
end repeat
end tell
do shell script “rm -f ” & p
do shell script ” > ” & p
This deletes the todo.txt file and creates a blank one immediately, essentially clearing out all tasks within it. For me, this just makes an instant OmniFocus new task maker. I like todo.txt instead of other editors because the new line in the text file isn’t created until I click add. In PlainText, sometimes OmniFocus ends up with portions of the task name as tasks because the script grabbed the task before I finished typing it. Todo.txt wins.
I made my Hazel rules:
Date Created is after Date Last Matched
Extension is txt
Name starts with todo
What I really want is a single script or even two scripts that will create new tasks in OF from a .txt file, link them to the OF task, while linking the OF task to the .txt file. Then when the OF task is completed/modified update the .txt file… This is reminiscent of OneNote / Outlook integration of tasks, that I miss on mac.
–Revised script to accommodate workflow containing meeting notes and journal entries where only some lines are action items
–Added filter for lines containing action items
–Added “exit 0” to suppress errors in log when grep finds nothing
–Added “quoted form” to enable handling of files with spaces, etc.
–My workflow is to create initial text in Drafts for iPad, proofread, then use Drafts to “send to Notesy”
–This script then monitors my ~/Dropbox/Notesy directory via Hazel on Mac
–Used Hazel condition “date last matched” is blank to ensure files are processed only once. Assumes a workflow with one file per meeting, event, or day that is not subsequently updated with new actions.
–I am really rusty with AppleScript. Comments welcome.
set p to POSIX path of theFile
set input_file to POSIX path of p
set l to paragraphs of (do shell script “grep ‘Action:’ ” & input_file & “; exit 0”)
do shell script “>” & quoted form of input_file
tell application “OmniFocus” to tell document 1
repeat with v in l
make new inbox task with properties {name:v}
end repeat
end tell
I’ve written a script that is a bit more involved that you may want to have a look at. It does some level of syncing between OmniFocus and a todo.txt file (which I have in Dropbox to share with my Android phone).
I do my primary data entry in OmniFocus, but like having the todo’s available wherever I am. I’ve been using the script for a while now and it seems to work well for me. Maybe you can get some benefit from it too.
The script and an explanation of how to use it is available here:
http://mckeehan.homeip.net/computers/omnifocus/index.htm
Let me know if you have a look at it.