Find Orphan Org-Roam Nodes

If you want to find orphan org-roam nodes, i.e. notes without backlinks, there are two quick and practical methods:

The first approach is to install org-roam-ui, which will visualise your nodes in a graph and thereby show the ones without any links.

The second approach is to use the ghastly script I've cooked up:

for f in *.org
do
  grep -oq "\[id:$(grep -o '.*:ID:.*' < ${f} | sed 's/.* //g')\]" *.org \
    && echo "HAS LINKS: ${f}" \
    || echo "IS ORPHAN: ${f}"
done

It assumes that your IDs are declared in a similar fashion to:

:PROPERTIES:
:ID:       cce9a447-9049-4a20-8b7e-9e376a714b30
:END:

… and that your nodes are linked like so:

[[id:cce9a447-9049-4a20-8b7e-9e376a714b30][example link]]

Enjoy!