How to hide attachment folders from the File Explorer pane

I’m looking at all those nice published notes online (for example: Obsidian’s help itself) and do not see any attachment file or folder anywhere. I only see the nice, resulting MD files listed as a nice hierarchy. I can’t seem to be able to reproduce that.

Been playing with the attachment options for the better part of the last hour and can’t set my mind on any viable option.

The vault I’ve created will likely hold a good number of attached pictures (i.e. reading/lecture notes, if that matters). Put them all in a single folder? Really not ideal — I plan to have dozens of MD files in there, themselves in sub- and sub-sub-folders. Put them in an “attachment” subfolder in the same folder as the MD file? Then I’d have attachment folders scattered all over the place in the File Explorer pane. Put them in the same folder as the MD file? Even worse, as I would be seeing all those attachments in the File Explorer all the time.

Is there something I’m not getting? I’ve started to use Obsidian having in mind that the File Explorer was the easiest way for me to navigate between my MD files, but now adding attachments to those files completely messes up that functionality.

The optimal classification, for me, would be in hidden “attachment” subfolders for each MD file — but I can’t either use dotted filenames, nor CSS to hide all those subfolders. Only found a way to hide e.g. a single “attachment” folder in the root of my vault that would be including all my attachments, and like I said, if I plan to have hundreds of them, this is not practical at all.

Anyone can tell me what I’m (obviously) missing here?


Just found out that you can embed images through HTML tags on dotted folders:

<img src="app://local/Users/cusername/Documents/obsidian_notebook/some_folder/subfolder/test.jpg">

Now I can set Obsidian to save attachments, by default, in a subfolder named “.attachments” in the same folder as the MD file, which is the ideal classification scheme IMO, but now pasting images directly in Obsidian’s editor no longer works.

So that’s some kind of workaround, although it’s not perfect.

Still waiting to know how all those nice published notes made with Obsidian hide all their attachments!

Oh alright, think I got it. Hiding some folders from the navigation pane is a function of the (paid) “publish” feature.

Oh well. Still love the software but having no way to (locally) navigate solely between MD files without all the clutter is really a turn off !

The ‘attachments’ don’t need to be in the same folder of MD file!
And you can embed attachments from outside the vault using something like this:
(file:/// is a mac path to local files)

1 Like

can or can’t?

1 Like

You’re right. Edited.

I realize that, but let’s say I want to keep attachments not so far from their original MD file, and that I otherwise plan to have several MD files in my vault (must be a common use case, right?) — then I’d want preferably attachments in either a subfolder of the folder containing the MD file, something like that.

In this case, well I’ll have most probably one attachment folder for every MD file, which in return makes the File Explorer much less usable.

Anyway I’ll resort to put all my attachments in a single folder for now and classify them again when we’ll have the option to hide specific folders in the File Explorer I guess. Bit of a pain, but I’ve explored all possibilities and there’s currently no “neat” way to keep attachments separated according to the MD file they belong (while hiding them in the File Explorer) without breaking up some functionality in Obsidian or making it a pain to add & adjust images.

My use case is to put in there my reading notes of academic publications, so keeping those several notes tightly classified is really a major requirement here.

There are two kinds of folders

  1. Ordinary folder that represents the structure
  2. Attachment folder which has the same name as the corresponding md file

Sometimes I also need to manipulate the attachment folder, so I didn’t hide it. I just gray out the attachment folder to distinguish it from ordinary folders. Assuming that the number of attachments is much larger than that of ordinary folders, the structure of ordinary folders doesn’t change very often, so I use CSS not() selector to exclude ordinary folders

In order to find ordinary folders, I wrote the following Python program. modify vault_path to the location of vault, and add the folders that need to be excluded to exclude_dir

import sys
import os

exclude_dir = ['.dropbox.cache', '.obsidian']
vault_path = r'D:\Documents\Dropbox'

def get_subdir(rel_path, subdir):
    rel_path += '/' + subdir
    print(f":not([data-path='{rel_path[1:]}'])", end = '')
    l = os.listdir()
    for f in l:
        if os.path.isdir(f) and f + '.md' not in l:
            get_subdir(rel_path, f)

print(":not([data-path='/'])", end = '')
l = os.listdir()
for f in l:
    if os.path.isdir(f) and f + '.md' not in l and f not in exclude_dir:
        get_subdir('', f)

input('"Press Enter to continue..."')

Add program printing to the CSS below and use the css snippet in your vault

/* add ":not([data-path='xxx']):not([data-path='yyy'])..." to the next line */
    color: LightGray;