Incentive
I index my Obsidian notes inside DEVONthink (DT) to take advantage of its algorithms to analyze the contents and suggest related documents to me. But when I’m viewing the indexed notes in DT, I often need to open it in Obsidian, which was cumbersome to do manually.
After URL schemes were released, I realized I could reduce the friction in my workflow by somehow automatically populating the URL
metadata field of the indexed notes with their URL schemes. This way, jumping from DT to Obsidian simply takes a shortcut, ⌃⌘O, to launch the URL.
I managed to put together a DT Smart Rule to achieve this. It can get the job done but the implementation is less than ideal, so any suggestions are greatly appreciated.
Dependencies
-
url-decode-encode-cli, a
npm
package used for URL encoding the note titles.-
npm
is needed to install the package, so I needed to install Node.js first, although I could safely uninstallNode.js
after the package was installed vianpm
.
-
Smart Rule setup
on performSmartRule(theRecords)
tell application id "DNtp"
repeat with theRecord in theRecords
set currentURL to the URL of theRecord
set encodedTitle to do shell script "(export PATH=\"/usr/local/bin:$PATH\" && printf '" & the name of theRecord & "' | url-encode)"
set obsidianURL to "obsidian://open?vault=zettelkasten&file=" & encodedTitle
if currentURL ≠ obsidianURL then
set the URL of theRecord to obsidianURL
end if
end repeat
end tell
end performSmartRule
How it works
- The search scope is my only Vault, “Zettelkasten”. I configured it to Exclude Subgroups because my notes are in the Vault root and subfolders contain attachments, templates, etc.
- The rule is triggered when the note is opened (clicked) in DT.
- The rule will assemble the Obsidian URL scheme and check against the current
URL
metadata field. If they’re not the same, theURL
field will be overwritten with the newly assembled URL; otherwise the field will be left untouched.- Because the rule assembles the URL scheme every time it’s triggered, the
URL
field will always be up-to-date even after the note title is changed. - Because the rule will not overwrite the
URL
field if it already contained the up-to-date URL scheme, the indexed notes won’t be modified every single time you open it.
- Because the rule assembles the URL scheme every time it’s triggered, the
- Simply use the shortcut ⌃⌘O to open the
URL
of the selected note, which will open the note in Obsidian.
Limitations
- Depends on
url-decode-encode-cli
to perform encoding - I only use one Vault and store all notes in the root directory, so I hardcoded the
vault=zettelkasten
part into the AppleScript. You may need to modify the script depending on your Obsidian hierachies.