Find files that do not have YAML headers?

I would like to find all the files in my vault that do not start with YAML headers: ---

I could not find a plugin that does what I need.

I read but could not understand various threads about using regex for vault-wide searches, and I could not adapt the regex examples to work as I need them to.

Is it possible with a plugin, core query, regex, or anything else to search all the files in the vault and find those that do not have YAML headers?

TIA :sweat_smile:

This small Dataview query gives you a list of files where frontmatter is equal to 0 (no values):

```dataview
TABLE file.frontmatter AS "Files without Frontmatter"
FROM ""
WHERE length(file.frontmatter) = 0
```

I tested it in my vault, and it works fine. There is still a place for improvement, but it’s a good starting point.

Cheers, Marko :nerd_face:

2 Likes

:purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart::purple_heart:

THANK YOU so much. And better than having to use VS Code and switching between apps. Genius.

:pray:

1 Like

You’ve also got an option of using dataviewjs and scanning the metadataCache to see if there is a frontmatter section at the start of the cache.

Just wanted to mention it, although that would require a little more coding compared to just checking the size of file.frontmatter. There might also be a difference with regards to who illegal frontmatter is reported in the two alternatives.

Which leads to the most expensive version of actually scanning the first line of every file in the vault.

1 Like

Many thanks. DataviewJS is way beyond what I can understand, but I appreciate the extra info. The solution provided works perfectly for my needs, so I will use that.

:pray:

1 Like