obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Exclude subfolders?

Open filmgal opened this issue 4 years ago • 3 comments
trafficstars

Is there a way to exclude subfolders from a list so that the results display only those pages that are in a root folder? I've tried

list from "Recipes"
where !contains(file.path, "Recipes/")

The forward slash is not understood as part of the exclusion until a letter is added after it, e.g., "Recipes/A", "Recipes/B", etc. which means each subfolder would need to be explicitly excluded.

filmgal avatar Apr 06 '21 18:04 filmgal

Hmm, I should look into an easier way of doing it, but you can achieve this with regexmatch:

LIST FROM "Recipes"
WHERE regexmatch("Recipes/[^/]+.md", file.path)

This effectively discards any paths which have another '/' in them (i.e., in a subfolder).

blacksmithgu avatar Apr 06 '21 19:04 blacksmithgu

I'd like to add to this, along with excluding subfolders, I feel it'd be important (and useful) to be able to indent the subfolders' contents if you don't want to exclude them.

This would enable you to build a full, proper index.

firinael avatar Apr 14 '21 20:04 firinael

@firinael can you explain what you mean by "indenting contents"?

AB1908 avatar Jul 25 '22 12:07 AB1908

Closing as duplicate of #66

AB1908 avatar Oct 19 '22 08:10 AB1908