Dataview Table Orphans (frontmatter)

I try to build a dynamic list of my orphans to edit them.
Problem: Most of my md-files have specified a parent per frontmatter-attribute “parent”.
This is not recognized as linked.
Therefore I wrote this dataview, but the result of this code includes the files with a parent.

table dateformat(file.mtime, "yyMMdd-HH") AS "LastMod"
from ""
where length(file.inlinks) = 0 and length(file.outlinks) = 0 and !exists(parent) or parent = ""
sort file.mtime desc

How have I to change the code?
Do you have a link for me where I can learn how to automatically convert the parent entry into a link that releases the file from its orphan status?

I haven’t tested this and I’m not 100% on exactly what you’ve got set up in your front matter, but I think your logical comparisons arent quite right. Try this:

table dateformat(file.mtime, "yyMMdd-HH") AS "LastMod"
from ""
where (length(file.inlinks) = 0 and length(file.outlinks) = 0) or (!exists(parent) or parent = "")
sort file.mtime desc

As for converting the parent field to a link, I think you’d need to do that either with a regex replacement across all files, or a script. I don’t know of a plugin that does that soecifically.

My frontmatter is:

author: Name
title: tbs frontmatter
subtitle: XXX
parent: "[[☝️-index-XXX]]"
prio: 0
frist: 00-00-00

and on your code-proposal I get the following message:

Dataview: Every row during operation ‘where’ failed with an error; first 3:

  • Unrecognized function name ‘exists’
  • Unrecognized function name ‘exists’
  • Unrecognized function name ‘exists’

Many thanks for your hints.

Finally back at my computer, this achieves what I think you want:

TABLE dateformat(file.mtime, "yyMMdd-HH") AS "LastMod"
WHERE (length(file.inlinks) = 0 and length(file.outlinks) = 0)
  OR !parent
sort file.mtime desc

It should give you a list of all files that aren’t linked to anything, and also don’t have “parent” field defined with content. If/when you convert the “parent” fields into being actual links, you could then remove the OR !parent line if you wanted.

1 Like