View Single Post
Quote:
Originally Posted by Lusule View Post
I would like an apple script that takes all my available tasks from Omnifocus and outputs them to shell. I could then use this script in Geek tool to embed my active tasks list on my desktop where I can see it.
I would probably use Sqlite to do this - designing an SQL query that fetches the list you want.

"Available" is used in quite a complex sense in the OF filter system - (tasks which are neither waiting their turn in a sequential project, nor already completed, nor deferred by a future start date (either of their own or inherited from a project or Single Action list), nor out of action because their project or context is on hold or dropped).

I notice, however, that you also use the word "active" to describe the list you want, so perhaps you simply want all tasks which are not completed ?

In any case, a prototype of what you need might look something like this:

Code:
property pstrDBPath : "~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property pstrFieldDelimiter : tab


-- set strQuery to "PRAGMA TABLE_INFO(Task);"

set strQuery to "
select name from task where dateCompleted is null;
"
runquery(strQuery)

on runquery(strQuery)
	set strCmd to "sqlite3 -separator '" & pstrFieldDelimiter & "' " & pstrDBPath & space & quoted form of strQuery
	strCmd
	do shell script strCmd
end runquery
and you can get a list of the other available fields, and their data types by running the query:

Code:
 PRAGMA TABLE_INFO(Task);
Note that the SQL structure of the OmniFocus cache can change from version to version, so you might have to amend the code next time OF is updated.

Last edited by RobTrew; 2010-11-19 at 09:15 AM..