# Org-roam function to find file name based on title

**URL:** <https://org-roam.discourse.group/t/org-roam-function-to-find-file-name-based-on-title/2067>\
**Category:** Development\
**Created:** [September 26, 2021, 4:01pm UTC](https://org-roam.discourse.group/t/org-roam-function-to-find-file-name-based-on-title/2067 "2021-09-26T16:01:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nrvale0](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@nrvale0](https://org-roam.discourse.group/u/nrvale0)\
**Post date:** [September 26, 2021, 4:01pm UTC](https://org-roam.discourse.group/t/org-roam-function-to-find-file-name-based-on-title/2067/1 "2021-09-26T16:01:11Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [September 26, 2021, 4:14pm UTC](https://org-roam.discourse.group/t/org-roam-function-to-find-file-name-based-on-title/2067/2 "2021-09-26T16:14:29Z")

</div>

If you have only one inbox file (doc?), you can create it with any finename (e.g. [inbox.org](http://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.

---

<div class="post-metadata">

**Author:** ![nrvale0](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@nrvale0](https://org-roam.discourse.group/u/nrvale0)\
**Post date:** [September 26, 2021, 4:23pm UTC](https://org-roam.discourse.group/t/org-roam-function-to-find-file-name-based-on-title/2067/3 "2021-09-26T16:23:34Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [October 3, 2021, 5:52pm UTC](https://org-roam.discourse.group/t/org-roam-function-to-find-file-name-based-on-title/2067/4 "2021-10-03T17:52:52Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![ThomasFKJorna](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@ThomasFKJorna](https://org-roam.discourse.group/u/ThomasFKJorna)\
**Post date:** [October 19, 2021, 9:59pm UTC](https://org-roam.discourse.group/t/org-roam-function-to-find-file-name-based-on-title/2067/5 "2021-10-19T21:59:31Z")

</div>

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:

```auto
(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.
