Recording and using the date of last access in org roam files

2026-01-15

I use org roam for “organizing” my notes and one problem I have is that I take a note and forget about it. Other people seem to resort to rendering graphs for node connections, to find “orphaned” nodes. But that does not work for me; just because node A links to B does not mean that I will remember both of them.

This is why I decided to record the last time a note was accessed into the respective file. Then, once a week I look for notes that do not have such a date entry. These are notes that I have never accessed since I introduced this change and then I can decide to keep them or delete them.

At some point, all notes wil have such a date. Then I will be able to order them by “last accessed” and look at the oldest ones.

For storing the date, I use this code:

(defun my-org-roam-store-access-time ()
    "Store the current access time in the PROPERTIES drawer of the current node."
    (interactive)
    (save-excursion
      (beginning-of-buffer)
      (org-set-property "LAST_ACCESSED" (format-time-string "[%Y-%m-%d %H:%M]"))
      (save-buffer)))
(global-set-key (kbd "<f5>") 'my-org-roam-store-access-time)

Note that I use the F5 key to access a roam note from anywhere, therefore this works for me.

Finding a note that was never accessed is very easy:

grep --files-without-match LAST_ACCESSED ~/org/roam/*.org | shuf | tail -n 1

If you have read so far, I hope this helps you. Feel free to mail me any comments.