Exclude all sub-folders in dataview query

Things I have tried

I’ve tried using wildcards in my source for example – from “somefolder/*”

What I’m trying to do

I want to be able to create dataview searches that exclude subfolders for example, list all notes in the root directory only, or list all notes in the first level of a sub folder, but none of the notes in the sub folders sub folders.

Within the metadata of file, you’ll find the folder options, which is listing the folder a given file resides in. This can be used to our advantage in this situation.

## From the folder "Somewhere/over/the"
list where file.folder = "Somewhere/over/the"

## From the root folder
list where file.folder = ""

Which in my test vault produces:

1 Like

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