A dynamic dataview orphan-finder

I’ve seen several orphan-finding and dynamic MOC / index dataviews, but still can’t create what I would need to stop relying on folders.

The typical auto-MOC shows “all inlinks to this files but no outlinks”. And orphan-finders show, “all files not linked to this file” , or “all files with no outlinks or inlinks”.

I’m trying to go one level deeper, to create “show all files that aren’t linked to this file’s outlinks”.


For example, Home MOC setup like:

[[Personal]]
[[Household]]
[[Business]]

Dataview: show all files that aren’t linked to any of the above (outlinks of this file).


I know how to set this up manually, adding each link to the DV code.

Is there a way to get it to work without having to update the dataview everytime I add a link to the Home MOC? That way I can keep adding to this Home MOC, and anything linked to whatever I add, I will consider “filed”. Anything not linked to whatever is on it, I want to surface, these are the orphans I’m looking for.


What I’ve tried many variations of:

List from ""
where !contains(this.file.outlinks, file.inlinks)

paging @mnvwvnm any advice would be much appreciated!

Not easy to understand your goal, sorry.

What you mean by “linked”? outlinks and inlinks?

If I understand you correctly, you’re asking to list all pages that aren’t linked to from either your top-level index or the outlinks (children) of your top-level index.

In my case, my top-level index is called “Reference Index”. This query shows me the first 30 pages that are not linked to from “Reference Index” or any of its outlinks.

```dataview
TABLE inlink, inlink.file.inlinks
FLATTEN file.inlinks as inlink
WHERE inlink != [[Reference Index]]
WHERE !contains([[Reference Index]].file.outlinks, inlink)
LIMIT 30
```

Is this something like what you’re looking for?

Sorry @mnvwvnm, I wasn’t more clear. I meant all files that are not linked to or from this file’s outlinks. Neither inlinks or outlinks.

Yes @Craig I think we’re talking about the same thing. Thank you for the suggestion! But it still surfaces this file’s outlinks for me, though I did add one line, to focus it on a folder. After the “TABLE” line, I added

FROM "Δ"

(that’s what I named my project folder)

So, taking this schema in consideration:

you’re interested in “e”, “f” and “g”

If yes, for test purposes, try this query:

TABLE file.inlinks, file.outlinks
FROM "Δ"
WHERE !filter(this.file.outlinks, (o) => contains(file.outlinks, o)) OR !filter(this.file.outlinks, (o) => contains(file.inlinks, o))

(but I’m not sure about the results…)

Yes! (if [[A]] [[B]] [[C]] are in the body of “current.md”)

I think your code is close! I see the file.inlinks field changing when I add [[B]] to current.md

But it still shows [[B]] and [[h]] in the table

Maybe I need more time to test with more examples… but for now try this:

TABLE file.inlinks, file.outlinks
FROM "Δ" AND -outgoing([[]])
WHERE !filter(this.file.outlinks, (o) => contains(file.outlinks, o) OR contains(file.inlinks, o))

Thank you! It seems like it’s doing exactly what I was asking for!
Though I prefer it into a simple list form with:

List
FROM "Δ" AND -outgoing([[]])
WHERE !filter(this.file.outlinks, (o) => contains(file.outlinks, o) OR contains(file.inlinks, o))
sort file.name asc

I hope more people will see this post. I’m surprised anyone interested in dataview MOCs isn’t looking for this solution. Its like using a single Dataview to emulate the functionality of folders. My biggest problem with using fewer folders is that notes get “lost”. I can’t tell what has already been “filed”. This solves that with a single Home.md note and a single dataview. It should be built-in! :grinning:

Another helpful view, if you want this orphan dataview to be on a different note, but still referencing your “Home MOC” note, try:

List
FROM "" AND -outgoing([[Home MOC]]) AND -#tag_to_exclude
WHERE !filter([[Home MOC]].file.outlinks, (o) => contains(file.outlinks, o) OR contains(file.inlinks, o))
sort file.name asc
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.