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:
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 “^=”.
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.
Thank you so much!
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!
Tried now another suggestion via regex, without success. still, wenn entering [[randomfilename.docx]], then also temporary office files are included like ~$ndomfilename.docx.
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.
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?
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.