Format folder when it exceeds a number of files

What I’m trying to do

I’m wondering if there is a way with CSS snippets to change the formatting (e.g. add a background colour, underline or make it bold) of a folder in the file explorer when the number of files within it exceeds a certain value.

Eg: if a specific folder contains more than 10 files, this formatting is applied.

Things I have tried

Plugins: I was originally looking for plugins that would specify the number of files in a particular folder next to it in the file explorer, such as File Explorer Note Count and Novel Word Count. Neither of these allowed me to select specific folders, they just showed the number next to all of the folders in the vault, which wasn’t quite was I wanted. I checked and it’s an existing feature request for both plugins but so far has not been implemented.

CSS: Then I realised I don’t necessarily need to know the specific number of files in the folder, but knowing that the number is above a value would be enough. I thought this might be possible with CSS but I’m not very familiar with it, so I thought I would ask here just in case.

Forums: I did check Google and the forums to see if anyone had already asked something similar, but most of my searches have just come up with threads about the maximum number of files or folders that Obsidian allows in a vault.

Alternatively if anyone knows of any other plugins that would solve my problem I’m open to trying anything. Thanks in advance for any suggestions!

If the folder is collapsed, there’s no way to know (from the DOM) how many elements it contains, because those elements only exist in the DOM when the folder is expanded. This makes it impossible to apply a different style using CSS.

A plugin could add a class to folders with many elements, which would allow them to be styled differently. I’m not aware of any plugin that does this.

OK thanks for letting me know :slightly_smiling_face: I’ll keep an eye out for plugins that offer the feature.

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