Hiding only empty folders

I have a folder that contains about 200 sub-folders. All the subfolders are necessary for me to have, but I only need to deal with the folders that actually have files in them. Is there a way to hide ONLY the non-empty folders? I tried a select filter that hid non-matching items, but it didn't work.

My filter:
Deselect matching items, hide items that don't match
Type match folders only
And size match is greater than 0 bytes

--chriscrutch

Opus displays the size of an empty folder as "empty" not "0". This is why your filter is not working. I think this has already been reported (thus my knowledge of it). I will ensure it is reported.

Unfortunately, I don't have a workaround off the top of my head. Let me ponder this a bit and see if there isn't some way to do what you are after. Someone else may also jump in here and help to in the mean time.

I thought the "empty" thing was likely the cause, but I wasn't sure. Thanks for thinking on this.

--chriscrutch

You could turn on one of the (Total) File or Sub-Folder count columns and sort by that to separate the empty from the 0-byte folders, if you want. Then shift-click select them all and hide the selection.

nudel,

That certainly would work, although I was hoping for a solution that I could implement either permanently using a folder format (or similar) or with a one-off button click. If I'm going to have to scroll to find where the file-count column stops being zero, then I can just sort by size (a column already in my normal view) and shift-click select those and hide the selection.

--chriscrutch

PHPBB_IMPORT_WARNING CODE_NEAR_LI

EDIT: Solid my butt! :angry: Readers, this post is entirely inaccurate. This should serve as a fine testing example. You cannot find root causes to issues or certify the results of an operation, without comprehensive test cases. I had forgotten to include a folder with a size > 0 in my test cases. As a result, I thought my proposed solution worked. Well it doesn't.

ORIGINAL POST

Okay I have a solid workaround now. :smiley:
[ol][li] Create a filter to select the opposite of what we are looking for.
There are three sizes we must be concerned with:[ul][li] Size > 0 - this will be any file or folder that is not empty.[/li]
[li] Size = 0 - this will be empty files and folders that contain empty subfolders. We won't be able to hide these (at least until I figure out how to hide them).[/li]
[li] Empty - this is what we are looking for and will only apply to folders (empty files have size=0).[/li][/ul]
The real issue is that we want to hide the empty folders, but there is no way to select them--they have a size of "empty" not "0". So we must take the long way home and select everything else first.

[ol][li] Open an Advanced Selection dialog. By default this predefined command can be accessed in Edit Menu > Select..., or by pressing Ctrl+S.
Otherwise, you can also find it in Customize > Commands > Category = Edit.
[/li]
[li] When the Select Files dialog opens, click on the Advanced button. This puts us at the Opus Filter System dialog.
[/li]
[li] We need to define a filter and save it so it can be re-used by a toolbar button that we will create in a moment. Create the filter displayed in the attached screen grab. Here's are the rules of the filter:

Size Match Is Greater Than 0 bytes Or Size Match Is Equal To 0 bytes
This will select all files and folders greater than or equal to 0 KB, leaving all folders with a size of "empty" unselected. Save this Filter, naming it: "NotEmpty" (no quotes)
[/li]
[li] Exit the Advanced Selection dialog[/li][/ol][/li]
[li] Create the toolbar button. Okay now that we have a filter that will select everything but what we are working for, we will use it like this:[ol]
[li] We must first ensure nothing is selected. This is extremely important, otherwise our button would add to any current selection, which could result in unhiding files or folders we want to hide, or hiding ones we don't want to.
[/li]
[li] Since in this case we cannot filter for what we want to hide, we must select the opposite of what we want to hide (using our saved filter NotEmpty).
[/li]
[li] Then we invert the selection, which results in selecting only the folders we really wish to hide.
[/li]
[li] Then we hide what is selected. (This step can actually be combined with the one above to save time.)[/li][/ol]
The resulting code is

Select None Select FILTER=NotEmpty Select INVERT HIDESEL [/li][/ol]
Here is an exported Opus toolbar button I've already created and tested, that uses the NotEmpty Filter, to hide empty folders. This button will not work correctly, unless you also create the NotEmpty filter that it relies on.

<?xml version="1.0"?> <button display="both" effect="saturate"> <guid>{DF055FAE-486C-4965-9D56-E2888B51B14D}</guid> <label>Hide Empty Folders</label> <tip>Hides empty folders (folders with no files or subfolders). NOTE: If a folder contains an empty subfolder, it is not empty.</tip> <icon1>36</icon1> <function type="normal"> <instruction>Select None</instruction> <instruction>Select FILTER=NotEmpty</instruction> <instruction>Select INVERT HIDESEL </instruction> </function> </button>

To get the button above to your toolbar:[ol][li] Copy the text from the code box above.[/li]
[li] Right-Click any Opus toolbar and select Customize.[/li]
[li] Right-Click on the specific toolbar you wish to add the button to and select Paste.[/li]
[li] Exit customize mode.[/li][/ol]

:imp: Blast it!

I'm sorry the above method will not work.

It will eventually hide folders that are not empty. It seems Opus cannot even select a folder whose size is greater than 0. I did not put a folder that had a size> 0 in my test cases so I missed this.

Ken, thanks, but I've tried it, but your filter seems to hide all folders whether they're empty or not.

I triple-checked my recreation of filters and buttons.

--chriscrutch

Yeah I caught it too. It's nothing you did. I had bad test cases.

It seems that Opus cannot filter at all based on the size of a folder. So it's not just folders with size= "empty" is folders of any size it can't filter on.

I will be filling this issue with GPSoftware right now

I guess we were replying at the same time. :slight_smile:

Thanks for trying, Ken. I appreciate that you put so much effort into this.

--chriscrutch

Hi all,

Interesting topic, ive only just spotted it. Anyway thought I'd mention that I was also looking for something similar to this a while back. In my case I had a few folders with hundred and hundreds of sub-folders which would periodically end up with quite a few of them being empty. I wanted a quick way to find and then delete these empty folders. Aside from the manual steps already outlined in your thread, I couldn't find a way to do it. Posting on the forum I received a few tips but nothing could quite do it. Eventually, I think I submitted it as a bug. Greg P was very helpful but I think he ended up putting it on his wishlist for future inclusion in the product. Can't remember how the thread went, but if you search on my name you'll probably find it.

Cheers
Quad

I have just submitted another official feature request which included two things:[ol][li] Filter folders based on size.[/li]
[li] Filter based on Size Is empty. This is not the same as size= 0 since a folder containing and empty subfolder has a size of 0 bytes but is not technically empty.[/li][/ol]As I understand it, The first one will be the biggest issue. Opus would have to recursively calculate the sizes all subfolders within a lister or search path, in order to ascertain if they match the criterion or not. Presumably, Opus would have to save this information to a temporary file or an array for filter comparison purposes, before actually starting the selection, or search. It could be quite a performance hit. And I don't know how it would work in real time with other processes writing to files while this takes place.

By the way, this is not a bug

[quote="The authors of The Opus File Filter System section of the User Guide"]• Size
Matches files (not folders) based on their size. You can choose from greater than, less than or equal to. To test for files between two sizes (for example, greater than 5 KB and less than 20 KB), use two separate Size commands conjoined with And.[/quote]

Hello ,
I haven't had time to comprehend all that has happened here today.
I do have one quick observation.

The notion that a folder is 'Empty' is entirely different than the notion that folder is of size zero bytes.
I haven't looked into this for a long time now, but I think folders are of the order 4 bytes or something.

I know that the commands of the command processor replacement 4NT can solve this problem.

Regards and Luck,
Porcupine

Yep, we established this in my post above.

Would you believe possibly "Yes" and definitely "No" at the same time?

I created some rather comprehensive test cases today before submitting my issue report. In one test case, I have a folder that contains 5 nested subfolders (each inside the another). Each subfolder is otherwise empty. Opus reports this main folder's size as 0 bytes in the Size (bytes) field. Opus also reports the Size on Disk (bytes) field at 0 bytes.

I also create several .txt files that contain 0, 1, 2, 3, and 4 bytes. Opus reports each of the non-0-byte files as the number of bytes of data they contain in the Size (bytes) field. However, Opus reports all of these files as 4096 bytes (1 KB) in the Size on Disk (bytes) field. However, the 0-byte files were still reported as 0 bytes in both fields.

To the best of my understanding (which is only semi-educated on this subject at best), folders in Windows have no size unto themselves whatsoever. The test cases above support this, as well as supporting that empty files have no size unto themselves. It is not until data is actually written inside of a file, that a file gets any size (as the operating system reports size).

As far as I'm am aware, the reason is that the meta data (Name, security permissions, attributes, dates, et cetera) for both folders and files are merely records in a File Access Table for FAT/ FAT12, FAT16, or FAT32 file systems; or, records in a Master File Table for NTFS file systems. While these table records would surely consume hard drive space (this may be where your 4 KB comes into play), this record's size is not actually calculated as part of the size of the folder because it is already included in the overhead of a formatted partition. This is one of the reasons why a formatted hard drive partition has less available space than an unformatted one--no FAT or MFT has been written to it yet. Both the MFT and FAT grow as the number of files and folders on the drive grows, but the size of these records is never reported by the operating system as part of the size of a file or folder. (However, the size of this record would have to become part of any data transmission, as the meta data would have to included and transmitted during a file copy or Internet up/down-load.

The problem, for our Opus filtering purposes, stems from the fact that folders have no size attribute at all, but files do. Folders are the hard drive equivalent of dividers in a Library Card Catalog with the letters of the alphabet embossed on them. They do not really take up shelf space and are just away to divide data. They exist only in the Card Catalog (the FAT or MFT) but not on the book shelves (the file storage area of the hard drive partition).

To observe this, you need only run Windows Explorer, and browse to a folder containing a subfolder with a HUGE amount of data inside, such as the folder that contains your main Music folder. Right-click on your Music folder and select Properties. If you eyes are quick, you will notice Windows performing a real-time calculation of the folder's size (the larger the folder, the easier it is to notice this). Windows is scanning all the folders and files and is adding up the sizes right in front of you. This would be the same as a librarian counting the total number of pages of all books starting with the letter "A" by reading the number of pages of each book in the "A" section of its Card Catalog entry and tallying it up in her calculator. The folder size is not actually stored anywhere.

Opus, must also perform the same calculation. And when a filter is applied for selecting of searching for files, Opus cannot compare a size parameter against a size that does not yet exist. Opus would have to recursively calculate all the sizes prior to performing the Filter match comparisons.