Org-roam function to find file name based on title

Hello, folks.

I’m working on some Org Roam capture templates for my semi-GTD flow. I’d like to have a template that drops a TODO into the doc titled “Inbox” but I cannot seem to find an org-roam function that can find the filename based on the title. Another option might be to find the correct file using a substring match of the file name but that sort of punches down through the Org Roam abstraction layer and I’d prefer not to do so.

Thoughts?

Thx!

If you have only one inbox file (doc?), you can create it with any finename (e.g. inbox.org) using find-file (or whatever), give title “Inbox” and ID; it will become a normal Org-roam node.

You can find the filename from a title via the node instance. But that seems to be overkill if you can just create a file like above.

Hey, thanks for the reply. The Inbox file (and others GTD-related) were created from within org-roam and they have dates embedded in file name. To your point, I guess I could rename the files as just “Inbox.org”.

I may do just that if there’s not an easy way to query them. Can you elaborate on the node instance scenario? As in what functions I might use?

thx

I’d just change the filename.

For “instantiating” a node, have a look at this part of the manual
https://www.orgroam.com/manual.html#Accessing-and-Modifying-Nodes

There are also examples in the wiki on GitHub repo.

Alternatively, you could look into org-roam-node-from-title-or-alias.

As Nobiot said, I’d probably just rename the file or find the ID yourself, but there is a way to it. Here’s a function which does that:

(defun org-roam-find-file-by-title (title)
    "Find the corresponding file of a node with title TITLE if it is unique."
   (if-let ((node (org-roam-node-from-title-or-alias title)))
             (org-roam-node-file node)
            nil))

Can’t promise that it doesn’t break (org-roam-node-from-title-or-alias errors on duplicate filenames) or that it’s fast, but it does work.