Graph view filter path: filtering also notes in root folder

What I’m trying to do

I want to filter the notes in the folder called “How to” (placed in my root folder).

Things I have tried

In the filter section of the graph view I added -path:"How to".
However, this filters also other notes that are in the root folder that have “how to” in their name - and even the ones that have only “how” in the name and “to” in the text.

Is there a way to only filter folders, and not notes in the root folder?

Try -path:"/How to/". This will still match subfolders with that name (and any files in them), but it won’t match files.

I don’t know why it’s matching only “how”, only “to”, and body text. You can try -path:(/How to/) instead but I don’t know if it’ll help.

@CawlinTeffid thanks for the reply, however -path:(/How to/) does not filter neither the folder nor the notes, and -path:"/How to/" filters the folder but still filters the notes…

BTW on the point of matching also “how” and “to” in the text I was wrong sorry, it’s only when how to is in the text!

Does the following solve your case: -file: "How to" path: "/How to" ?

This could potentially also limit notes within the /How to folder.

Whenever you start using / in the filter expressions, you enter the realm of regex. This can help you a lot, or confuse you a lot.

As I see it your request has two key parts:

  • Match folders in the root either starting with, or matching “How to”
  • Do not match files in the root folder having “How to” in the name

Both of these can be addressed with regex, and for easier verification I suggest doing the preliminary tests in the search pane.

Starting with “How to”

Try out path:/^How to.*?\//, which can be explained as match against the full file path which:

  • Starts with, ^, the leading text `How to``
  • Followed by the shortest random text, .*?, still matching the rest
  • Where the rest is an actual slash, \/, which is an indicator that the path will continue with more files and/or folders, so it rules out notes in the root folder

If only “How to”

If you need to match against the exact variant of the folder “How to”, this regex can be simplified to, path:/^How to\//, which has the same explanation, but it doesn’t allow anything between the “How to” and the literal slash.

1 Like

The regex expressions worked perfectly and thanks for the explanation!

I didn’t realize regex could be started within quotes.

I’m sorry if I implied that, but it doesn’t look like it either.

path: /^[zxyw]/ is in no way the same as path: "/^[zxyw]/". Sorry for any confusion. The first looks for path starting with any of the letters “zxyw”, whilst the second looks for a file path starting with that exact text (and I wonder who in their right mind would start a file path with that! :-D)

That’s where I keep my reverse alphabetical notes! :smiley:

1 Like

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