List files not backlinked to files with #MOC

What I’m trying to do

I am sure this has come up but search is giving me only close but not quite exact matches. List notes that does not appear in a MOC - #5 by holroy This is the closest but its a fairly complex table where I just want a simlple list.

I have regular notes and MOC notes that index those notes.

I eventually want most of my notes to be mentioned in (linked from) some MOC note (i.e. a note with a moc tag). Sometimes I have made notes that haven’t yet been mentioned in a MOC.

I want to generate a list (not a table) of all notes not mentioned in (forward-linked from) any note that contains the tag moc.

They aren’t orphaned - they link to other notes and are linked from other notes. They just won’t be linked from a MOC yet.

Managed to get it to work :slight_smile: This was the code!

FROM !#MOC & !#paper
FLATTEN list(map(file.inlinks, (f) => econtains(f.file.etags, "#MOC"))) as inMoc
WHERE file.folder = this.file.folder
  AND none(inMoc)