Applescripts to integrate DT2 with OmniFocus

I have added a simple utility script to this collection.

SetDBforOmniFocusFolder allows you to choose which DEVONthink database will be used for the selected OmniFocus folder. The default is “OmniFocus Notes”, but this script will offer you a list of the databases currently open in DT, and will store the path of the database you choose in the invisible note field of the selected OF Folder.

The current versions of the OpenProjFolderinDevon and OpenProjNotesinDevon scripts will then use the specified database for all OmniFocus projects enclosed by that folder and its child folders. (Except where any of these have been given their own database assignment by this script).

Working well here-thanks! Previously I had duplicated the integration scripts and hard coded each one to specific database as I did not use an ‘OmniFocus Notes’ database. That worked , but gave me additional clutter and complexity. This is a welcome addition.

This is also working for me. Like Greg, I had also edited the prior OpenProjFolderinDevon script so that the folder was created in the desired DTPro database. It worked, but this is much cleaner. Thanks for the hard for on this! I’ve been using these scripts for some time now and they’re terrific!

I’m not sure if this is possible but I’d like to know if it is possible to change the location within a DTPro database where new project folders are created. Because I use the Sync feature I would like these folders to be created inside of the Sync group/folder in my DTPro databases. Is this possible? If so, can anyone advise me how to accomplish this?

Will

Two thoughts:

  1. The link between an OF project and its DT folder should not be broken if you drag (or replicate) the folder into the Sync group. (The scripts now rely on position-independent URLs to maintain the links - folder hierarchies no longer have to be kept parallel).
  2. If you did want all new folders to start their lives as children of the Sync group, an option could be made to prepend “/Sync/” to the paths of new folders in the GetParallelFolder() function.

Thanks. I’ve spent some time lately studying Applescript but I’m not certain where such an option would be placed in the code below. Anyone have any advice on where to prepend “/Sync/” to the paths of new folders so that the resulting project folders in DTPro are created under the Sync group in DTPro?

on GetParallelFolder(oProject)
	set {strPath, strFolderDB, strProject} to GetProjPath(oProject)
	tell application id "DNtp"
		
		-- CHOOSE THE TARGET DATABASE
		-- EITHER FROM A PATH IN THE ENCLOSING FOLDER, OR FROM THE DEFAULT
		if strFolderDB ≠ "" then
			set strDb to strFolderDB
		else
			set strDb to (POSIX path of pstrDocsPath) & pstrDTDB & pstrDTsuffix
		end if
		
		-- 		set lstFound to databases where name = strDTDB
		-- 		if length of lstFound > 0 then
		-- 			set oDb to first item of lstFound
		-- 		else
		-- 			set strDb to (POSIX path of pstrDocsPath) & strDTDB & pstrDTsuffix
		set oDb to open database strDb
		if oDb is missing value then
			set oAnswer to display dialog "Create new Devonthink database at \"" & strDb & "\" ?" buttons {"Cancel", "OK"} default button 1
			if the button returned of oAnswer is "Cancel" then return
			set oDb to create database strDb
		end if
		-- 		end if
		
		set oLocn to create location strPath in oDb
		set URL of oLocn to pstrOFPrefix & (id of oProject)
		return oLocn
	end tell
end GetParallelFolder

If you download the latest .zip (ver 211)

You will find a new property at the top of each of the latest versions of the two scripts OpenProjFolderInDevn and OpenProjNotesInDevn.

Try editing


property pblnUseSyncAsRoot : false

to


property pblnUseSyncAsRoot : true

in both files.

Experimentation should, I think, reveal that they now create any new folders within the Sync group.

Any existing folders can be dragged or replicated into the Sync group without breaking the link from (or to) their OmniFocus projects. (As long as the note field of these projects contains a Devonthink hyperlink to the relevant folder.)

Thanks so much for making these changes. They seem to work just as you described although I had some older information in the OmniFocus folders and projects that caused some difficulties at first. This is easily remedied with OF projects: all you need to do is delete the hyperlink back to DTPro in the notes field. But not so easy in the OF Folders. My only way around old hyperlinks in the “invisible” notes field was to delete the old folder and create a new one that could then take the updated DTPro hyperlink.

Thanks, again. I really appreciate it. Your scripts have been extremely useful to me.

You should be able to clear a path from an OmniFocus folder by using the SetDBforOmniFocusFolder script and choosing the NONE option.

(First item in the menu).

This is magical - fantastic work, houthakker.

Though, as ever, wondering if it would be possible for one minor variation :slight_smile: - instead of storing oo3 files in the DT database for project notes, would it be possible to use just an opml file? I’d find this much more suitable to my requirements :slight_smile: And unfortunately, my applescript isn’t up to hacking this together myself.

TIA (but T anyway!)

Dave

These links no longer work. Any chance that someone here has these scripts archived??

Many thanks.

He changed servers a while back-try this link.

Excellent. Thanks!

Thanks, Greg – I’ve updated the link at the top of the thread now.

My memory is that if we import an OPML file into DT, DT generates a matching directory structure rather than a simple file. Perhaps others can correct me on that, or point us to a way of circumventing that response. (The obvious thing would be to change the file extension to .TXT, but would the plain XML text source of OPML really be a good vehicle for your notes in DT ? See attached …)

In the meanwhile, I have personally switched to using FoldingText’s Markdown-enhanced plain text outlines for my OmniFocus (and other) notes - they are light-weight, easily repurposed (and easily formatted through Marked ), and I find that they work very well in DevonThink for preview and search. (I had experimented with Tree, also an excellent and interesting outliner, but I found its previews a bit too small and illegible to work well with DT).

I may wait a moment before I post an update which offers the option of using FT outlines – the FT scripting interface is being extended and reframed right now, and may offer new food for thought :slight_smile:

In case anyone wants to experiment with using FoldingText plain text outlines for their OmniFocus notes (in lieu of OO3 notes), version 214 of the Project Notes script at http://bit.ly/OFOC-Devon should allow this.

There is a property at the top of the script:


property pblnPreferFTToOmniOO3 : false

If FoldingText is installed on your system, and you edit the above value to true newly created project notes should be used the FoldingText file format and extension - plain tab-indented text (optionally with Markdown adornments) and, by default, the extension “.ft”

I personally find FoldingText supports a very good intersection of the benefits of outlining and plain text - rapidly searchable, flexibly repurposable, and readily editable in DEVONthink for quick plain text adjustments. An interesting scripting interface too …

Thanks for sharing this-works like a charm here-very timely! Just last weekend I converted the last of my OO3 documents to text format as I’ve given a long-time friend OmniOutliner a rest.

Good, I’m glad that’s working for you.

@Davem (apropos importing OPML material into DT notes, rather than as nested DT folders)

One solution would be to import the OPML outlines into FoldingText outline format. I’ve drafted a script for doing this, of which you can find ver .007 at goo.gl/MeB9J

(and if you need a return trip back to OPML, I’ve drafted another script, with an FT to OPML export option)

Thanks for all the Folding Text scripts and ideas! I’ve also put OO3 on the back burner and turned to FT.

Good, I’m glad that’s useful, and yes, OO3 has been a good workhorse, and I happen to be using it this afternoon for an application which requires columns, but I do find that FoldingText works better for keeping note outlines in DevonThink.

(And there are cases in which FoldingText key/value tags and properties can actually be a bit more flexible than OO3 columns).

I found conversion from OPML to Folding Text / TaskPaper goes perfectly well but not so the return trip, from .ft or .taskpaper to OPML. Are there any updates to these scripts?

To start with, I was also troubled by DT’s handling of OPML. Until I found out that OPML items with notes, become DT text files with the full text of the OPML note and the title of the OPML outline item. Therefore, all OPML items with notes become DT text files, not folders. This can be good for certain scenarios. The same happens in Scrivener.