Hiding temporary MS Office files (~$xyz) in file explorer (CSS? regex?)

What I’m trying to do

I’m using MS office files within my vault have them settled just next to my notes. When opening the files with MS Word or MS Excel there are usually temporary files created. As these additional files make the list view in file explorer quite cluttered and are additinally popping up when searching, I need a way to exclude them from showing in Obsidian. I thought about filtering these files by the inital “~” or “~$”.


For example the following files should be excluded from file explorer and search:
~$HHFM W char.xlsx
~$st matrices fo.docx

Things I have tried

First apporach:
Excluding them by a CSS snippet, as shown here:

I tried the following snippets:
div[data-path$=‘~’]{display: none;}
div[data-path$=‘~$’]{display: none;}

However, “data-path$=” seems to work only with file extensions like ‘.docx’ or ‘docx’ (which does not help), but not with parts of the filename (e.g. ‘HHFM’ would not exclude all files with HHFM as well, just as an example). I don’t know CSS, but I guess “data-path$=” is not the correct CSS term. By further research I could not find the correct term to use here.

Second approach:
I tried via “Options > Files and links > Excluded files” to add a regex entry. I’m also not used to regex, but tried to understand it from different forum posts and regex101.com (wow, it’s complicated). Several different combinations did not change anything in the file explorer:


… and many other variations. How does this work?

In CSS, $= will only match if the data-path ends with ~$

A caret (^) is used to match at the beginning of the string.

In my brief testing, this works as expected:

[data-path^="~$"] {
	display: none;

Hope this helps…

Thanks a lot, but strangely it does not work in my case. Tried copy & paste of your code and other variations as well. When using the full name of the file, the file gets filtered by using “$=”, but not by using the caret “^=”.


[data-path$="~$fullnameofthefile.docx"] {display: none;}

→ file is excluded.

[data-path^="~$fullnameofthefile.docx"] {display: none;}

→ file is NOT excluded. Same with other files without leading “~$”. So, why the caret does not work here?

Hmm, not sure why it’s not working for you.

Have you tried the contains/wildcard (*) selector?

[data-path*="~$"] {
	display: none;

This also works in my testing.

CleanShot-Obsidian-New tab - Vault Name - Obsidian v1.6.0-2024-05-22-10.50.24


Bam, * works like a charm! I guess it would have been more elegant with ^ and the downside is that I may not name any file with ~$ in the middle or at the end. But why should I anyway. :wink:

Thank you so much! :heart:

However, it did not solve the exclusion from the search index. If there is any other idea how to achieve that, please let me know!

1 Like

Tried now another suggestion via regex, without success. still, wenn entering [[randomfilename.docx]], then also temporary office files are included like ~$ndomfilename.docx.



The “Excluded files” setting doesn’t hide things in the file browser — reread its description.

Yes, meanwhile that’s clear. But here I have two issues:

a) Hiding ~$files from the file browser, which is solved by CSS thanks to gapmiss.

b) Hiding ~$files from search and link suggestions, which is not yet solved. Your suggestions did point in the right direction. However, it does not seems to work and I need help to understand why.

I’ve never used the toggle, but Quick Switcher ++ has this option. That may cover the quick switching side of the issue.

Thanks for the tip! That could help additionally. However, then I still have to get the regex right to properly exclude files with ~$ in order to work. Does someone have an idea?

Another workaround I could imagine: Excluding files which are hidden in Windows. Is such a feature implemented somewhere? Or achievable via plugin?

I just tested my suggestion and it worked — the test file was pushed to the bottom of suggestion lists even when I typed the full name (minus the ~). Could you post a screenshot of your Excluded Files settings?

1 Like

AAAH, it should be downranked! Now I understand what’s meant in the description with “will be less noticeable in in quick switcher and link suggestions”. Sorry, that I did not get what you meant in the first place.

I tested it again, and the entry is downranked indeed. It’s OK as a workaround.

Thanks a lot for helping out!

1 Like

The “Excluded files” setting doesn’t hide things in the file browser — reread its description.

This option and its description make little sense. Why call it “excluded files”, when it does anything but exclude files?

OP’s question is one of the many use cases that could easily be resolved by an option that would in fact exclude files:

1 Like

Reread the description — it excludes files from multiple features.

Reread the description — it excludes files from multiple features.

Are we looking at the same description? This is a screenshot from 1.6.1:

This description talks about hiding files in some features, and doing it imperfectly in others.

1 Like

I don’t know what difference you see between “hiding” and “exclusion” in this context.

Also we are getting off-topic for this thread, which is already solved.

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