Applescripts to integrate DT2 with OmniFocus

With a little automation, DevonThink and OmniFocus work powerfully together.

I have written a few OmniFocus scripts which coordinate their interaction:

For instructions on installing Applescripts as icons on the OmniFocus toolbar, see:

Just uploaded version 002, which gives the DEVONthink records clickable links back to the corresponding projects or tasks in OmniFocus.

Thank you for these cool scripts! I have just written a short notice about them in my blog.

Many thanks! :smiley:

My GTD system is build out of OmniFocus and DEVONthink Pro Office 2. I’ve had a brief look at these scripts but I’m not entirely sure how you use them. Would you be so kind as to explain your workflow and how you put these scripts to use?

For the records I believe that the combination of these 2 products are awesome, once I’ve got a better understanding of how you use the integration I could kick my system into overdrive!

I install these four scripts onto the OmniFocus toolbar, where they enable me to:

keep the verbs in OmniFocus,
and the related nouns in DEVONthink 2,
linking them together.

Verbs: actions and their outcome descriptions.
Nouns: related files of various kinds, including detailed project notes.

(I don’t use attachments or notes in OF, all of that kind of thing goes into the matching DT folder, where I find it more fluidly accessible and more deeply searchable).

One of the scripts simply opens the matching DT2 project folder, (creating it if necessary) so that I can find the files I need, or drag some new files into it.

As I work through any (slightly more complex) project, I edit and refashion a running outline of it, to maintain a rich hierarchical view (richer than the view in working memory, that is) of where I am and where I’m going. I maintain my running project outline notes in an Omnioutliner file in the corresponding DT2 folder.

One of the scripts simply fetches this file (opening it in OmniOutliner, and creating it in the appropriate DT2 folder if it doesn’t already exist).

(Outlining is possible in OmniFocus (tasks and sub-tasks) but not particularly snappy, partly because of the good and solid database system that underlies OF, and partly because the default indent/outdent keystroke assignments are not the tab / shift-tab ones which my hindbrain habitually associates with outlining.)

The remaining two scripts, which send material from OF to DT, I simply use to archive things into DT, where they become quite powerfully searchable. Both scripts preserve the various fields of each OF record, one using OmniOutliner columns, and the other using TaskPaper text tags.

OF - OO and DT2, these were the three key components of my workflow and with these scripts they are going to work much more efficiently together, thank you so much !

I have a question for one of the DEVON developers.

These scripts are awesome and have a lot of potential. However, when I run these scripts, it opens up a new window of DEVONthink every time the script is run rather than in the already open database window…or making that database the active one if multiple databases are open. The file tree is also not visible initially. I have to switch databases and then back to the “OmniFocus Notes” database before the tree is visible.

I communicated with the scripts author, and he indicated that this was a problem with DEVON’s scripting rather than with the script itself. Is there any way to remedy these problems?

I take this to be an expression of interest: * in a way of automatically making the folder hierarchy visible in windows created by Open Window for Record.

  • and/or in a way of specifying the folder to be displayed by the front DT window.


Yes…I would like the folder hierarchy in DTOP to be automatically visible.

I would also like it if a new window for DTOP wasn’t opened every time I run the script…unless there are no DT windows open. It there is a DT window open for another database…I would like the “OmniFocus Notes” database to open in the same window…but become the active database.

Thanks for letting me know if this is possible. This is as good a reason as any to up the ante on my learning curve for AppleScript.

Are these scripts still supposed to be working? I’d love to be able to use the OO3 script. It puts an OO3 doc in the DT global inbox, as I’d hoped, but it also puts an empty folder in an “omniFocus Notes” database and freezes OmniFocus to the point that I need to quit it to get it working again … and I don’t know anything about Applescript.

It’s working on my system. On yours there seems to be a problem (timing issue perhaps) with getting the .003 from the Inbox to the new folder, where it should be.

What are your hardware and software versions (OF and DT, OSX) ?

All the latest - 1.7.4, 2.0b6, 10.5.8 (the latest version of Leopard, anyway). Unlike my Mac, a Powerbook G4 1.5 Ghz veteran of 2004-05.

I later realised I had to include my own database names and paths in the script, but the same lockup happens every time.

I think that this may be the problem. The script saves the .oo3 to the Inbox, and then tries to move it from the Inbox to the new folder. It takes a noticeable moment for the file to become visible in the Inbox through the scripting interface, and on a slower machine the prolonged delay may be causing a problem.

I will revisit the code over the weekend to see if it can be adjusted for slower hardware.

I have posted first drafts of a rewrite of two OmniFocus-DevonThink integration scripts at (See - Experimental version 2)

  • Open oo3 project notes in DevonThink for the selected OF project
  • Open a DevonThink folder for the selected OF project

These early drafts mainly aim to allow for more flexibility, doing away with the need to maintain parallel folder structures in DevonThink and OmniFocus.

[size=85](They achieve this by storing hyperlinks, in the OF project note field, to folders and oo3 documents in a DT database. When folders and oo3 notes documents are first created, they are, as before, initially given a DT folder path which matches the project folder path in OmniFocus. The use of DT hyperlinks means, however, that subsequent rearrangements of folder nesting, whether in DT or OF or both, will not break the link between the OF projects and the corresponding materials in DT).[/size]

Another goal of the redrafts is to address some reports of error messages arising when the “open project notes” script is finding or creating its oo3 notes.

[size=85](Using hyperlinks should improve the reliability of finding the notes, which no longer depends on file-paths remaining static within the DT database. In addition the mechanism used for creating a fresh oo3 note file has changed. Fresh note files are no longer copied from an .oo3template file in ~/Library/Application Support/OmniOutliner 3/Templates.

Instead, the script tries to copy the new note file from a document called Default.oo3 in the same folder as the script. If no such file is found, the new oo3 file is based on a Default.oo3 inside the script bundle.

Users who wish their notes files to have particular fonts and layout should, therefore, prepare a blank sample, and save it as Default.oo3 to the folder in which the script is stored). [/size]

As this is an early draft, there will be bugs, and anyone choosing to experiment with these scripts should back their data up. Bug reports will be welcome - please send them to houthakker72, which is a address.

I’ve updated the Save2DevnAs003 (OmniFocus to DT2) script to fix an issue which, on some systems, could lead to error messages relating to the oo3 file.

[I plan, at some point this boreal summer, to edit this (and the Save2DevnAsTXT script) so that they find/create links to DT2 project folders, and are no longer dependent on maintaining parallel folder structures in OF and DT.

If this seems useful, and I don’t appear to have done it, you can try reminding me at houthakker72, which is a gmail address]

A quick note …

It has come to my attention that copies of OmniFocus which are purchased through the Mac App Store have a variant bundle identifier. (the string .MacAppStore is appended to the default com.omnigroup.OmniFocus)

One of the headaches which this brings to scripting OmniFocus is that it gives a different path to the OmniFocus cache, and these scripts can not currently be run by Mac App Store versions of OmniFocus.

(These ability of these scripts to search OmniFocus projects notes for links back to Devonthink depends on querying the OmniFocus cache, and looking at the XML representation of the notes content.)

I am not planning to maintain parallel versions, and for lack of unlimited free time and a dual installation on which tests could be run, I am also not planning to try to maintain code which is equally accessible to both variants of OmniFocus.

My personal advice would be to buy OmniFocus direct from the OmniGroup, but if you already have an AppStore-purchased version, you will need to customize your version of these scripts by editing any occurrences of the bundle identifier string, to append “.MacAppStore”.

(I have posted a simple FAQ on the OmniFocus forum)

It’s looking better now … Ken Case at Omni has come up with some interesting code for dealing with a dual bundle ecology …

I think I can see a way of making the integration scripts work with both variants of OmniFocus …

I’ve posted a first draft of versions of the OpenFolderinDevn and OpenNotesinDevn scripts which attempt to allow for variant OmniFocus bundle identifiers, cache locations etc. [at the moment, essentially com.omnigroup.omnifocus.MacAppStore].

(If your copy of OmniFocus happens to have been purchased through the Mac App Store, I would be interested to know whether it can run them).

Thanks so much for this. After purchasing DT I was disappointed when I couldn’t drag folders from DT to Omnifocus Notes field and automatically create links. But these scripts appear even better than that, and work well so far. I look forward to incorporating this into my workflow.