How do I list notes from my main vault (that are not in any folders) using a dataview query?

What I’m trying to do

I’m trying to list the notes that are in my main vault but are not in any folders.

Things I have tried

I used a simple dataview query to pull the notes from the main vault but its pulling in all the notes.

Thanks for all your help!

Please show us what you’ve tried so far, and explain how you’d like it to work.

This is what I have so far. I don’t really have programming knowledge as such but I’m improvising from what has worked before. Here’s the dataview query I’m using:

List
FROM "[main vault name]"
WHERE file.name 
SORT file.ctime desc

If you want to display the notes in a vault other than the one you are in, this is not possible with simple dataview. If it’s in a particular folder in the vault you’re in, you’ll normally just put the folder name like this: FROM "foldername".

A few comments to your query:

  • FROM "some/folder" – From is used to limit the query to files of that folder or below. By default the queries will list all files from the current vault, and you can’t use this to select other vaults
  • WHERE file.name – Will limit your query to those having any non-empty file.name, aka all files :smiley:

Related to filenames there are three especially useful variables:

  • file.name - Lists just the file name (without the file extension)
  • file.path – Lists the full file folder and name with the file extension
  • file.folder – Lists just the folder part

So list only files in the main folder of your vault, and none below that you could use either of these queries:

```dataview
LIST WHERE !file.folder
```

or

```dataview
LIST WHERE file.folder = ""
```

Note that you don’t need to do something like FROM "" since that essentially lists all files in the main folder and all files under that folder (aka every folder there is in your vault). So you can just skip it all together in this case.

1 Like

Hey thanks so much for your response. This worked! :smiley:

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