Finding the currently open note using AppleScript

This was the subject of an older help request, and something I wanted to do as well.

Although Obsidian doesn’t have any of its own AppleScript support (which imo is pretty reasonable), its windows are visible to AppleScript. You can get at them like so:

tell application "System Events"
    tell process "Obsidian" to get title of front window
end tell

That gives you a window title like:

Short story ideas - textfiles - Obsidian v1.4.16

So there’s the title of your open note right there.

And if you combine that with a script that knows where you keep your vaults (e.g. my textfiles vault lives at ~/textfiles), you have a way to find out the title and path of the currently open note.

There are lots of ways you could do this; I posted a Python implementation of this idea on my blog.

1 Like