How to exclude from a search everything that isn't a note?

Hi, this must be a silly problem, but I frequently do this search “-tag:whatever” to find notes not tagged with whatever, so I can tag them. It works, but the search also shows all (a lot of) pasted images, canvas files, pdfs and anything that happens to be there but I’m not really looking for.

So:

  • is there a way to limit the search to only “regular” notes?
  • do I have to specify each kind of document I don’t want to see? If so, how do I write a search that excludes canvases? and images?

Forgive my ignorance, I’m sure that this must be easy, but I’m stuck and I ask for your help, please.

Do you put all your Attachments in a specific folder? If so, you could use that to exclude files in that directory. For example, if I wanted to find everything not tagged with #obsidian and not in my "_Attachments/" folder, I would search using…

-tag: #obsidian  -path: "_Attachments/"

A heavy handed solution would be to create a Dataview query to create a list of all notes not tagged with #obsidian.

```dataview
LIST
FROM !#obsidian 
```
1 Like

Most of my attachments are in their specific folder, so, after doing some house cleaning, excluding paths could be the solution. I’ll have to move all my canvases to a folder and exclude that one too, right?

I don’t use dataview yet but: how would that method deal with .canvas files in root?

Thank you!

-file:.canvas does the trick.

Thanks again @FsOver2 ! Problem solved!

1 Like

I’m glad you figured out a solution! :smile:

For good or bad, Dataview only returns results for notes (.md) by default. It ignores all other file types, including .canvas files. You can get fancy and get it to show other file types, but you need to be very intentional to do so.

If you choose to go down the Dataview path, you would

  • install the plugin
  • copy the code snippet I suggested earlier into some note.

The list would then dynamically be generated. You would be able to click links into the desired notes, and when you return back to the note with the list, the files you add the tags to will automatically be removed.

1 Like

I see, this would solve my problem in a much cooler way. One of these days I need to explore the Dataview rabbit hole, and your snippet is a good start. Thanks for being so helpful!

1 Like

Dataview is very cool and powerful, and a huge rabbit hole. Best of luck to you! :smile:

I do something similar to your original question in my Maps of Content. I place the following Dataview block at the bottom of all my MOC notes. For a specific MOC note, it creates a list of all files that link back to that MOC note but don’t have links to them from that MOC.

# Unlinked Backlinks
```dataview
list 
from [[]] and !outgoing([[]])
SORT file.name ASC
```

What this allows me to do is create backlinks quickly to a MOC and not worry about remembering to go to the MOC to create the forward link to the subnote. Later, when I have time for house cleaning, I have a list of notes pointing back to my MOC that need the forward links to be added. As they’re added, they’re automatically removed from the list.

Depending on your use case, you could modify this to use tags instead.

1 Like

That does it, knowing this months ago would have saved me lots of time and messy structures.
Down the rabbit hole I go! :grin:

1 Like