Label folder based on file count

Thank you in advance for your help and I apologize if this question has been asked before. (I couldn't find it.)

I am new to Directory Opus and would like to apply a label to subfolders based on the file count inside the subfolder. Please advise how to achieve this.

Thank you!

While that is possible, it would be quite slow, as it would mean reading the folder listing of every sub-folder each time you change to a new directory. If there are a lot of sub-folders, and/or they contain a lot of files, it might take a long time. It would also need some scripting (but I think there is already a script on the forum somewhere, although I couldn't find it from a very quick search).

If you just want to highlight empty folders, that has some overhead but a bit less (it'll only need to check if the folders contain anything, not list their entire contents). How to do that is here, but note that it won't differentiate folders which are literally empty from ones which contain only sub-folders or zero-byte files:

Thank you for your reply, Leo! I just need this functionality on a handful of folders, each with only one child folder and a maximum of about 30 files inside. I doubt speed would be a huge issue on my brand new ThinkPad. I am comfortable with scripting but very busy right now. When I have some more time I will take a look at how to implement scripts in DO but for now I will use the label example you included in your post.

Are you able to send a link for a good intro to scripting in DO or is the manual the best resource?

Thanks again!

If you want a super-quick solution, you could add the File Count column and sort or group by that.

For scripting, the Opus Manual menu at the top-right here has quick links to the main things, and the Buttons/Scripts part of the forum has lots of examples. We can help as well, if you get stuck.

Here are some scripts which do similar things to what you want. You can probably adapt or use them as inspiration to save time:

This isn't a column you could use for filtering, but shows how to enumerate folder contents in a script, which the other two scripts use:

Script columns can then be used in filters and labels, to e.g. apply a label if the script-column value is "yes" or greater than 10.

We can sometimes write scripts for you if we have time; more likely if you link your account and can provide some more detail on what you need, (e.g. Do you want the count to be recursive or not? And is the aim to always check for X amount of files, or to make that something you specify in the filter? If it's always X then the script could stop looking once it reaches that number, to speed things up a bit.)