Understanding search for Empty FOLDERS

Discussion related to "Everything" 1.5 Alpha.
Post Reply
ChrisGreaves
Posts: 678
Joined: Wed Jan 05, 2022 9:29 pm

Understanding search for Empty FOLDERS

Post by ChrisGreaves »

Please see also Understanding search for Empty FOLDERS
I ran an Advanced Search: search.php?keywords=empty+folder&terms= ... mit=Search and read the posts.
From that I built a table with a few sample search commands:-
FunctionCountComment
T: empty: 74Shows folders without any files or folders in them
T: childfoldercount: size:0 23Shows parent folders whose entire tree consists of empty folders and/or zero-length files
T: childfilecount: size:0 79Shows folders whose leaf-nodes contain only zero-length files. Note that within the tree there may be data files of non-zero length.
T: child-file-count-from-disk:01,646Shows folders whose leaf-nodes contain one or more zero-length data files. Note that within the tree there may be data files of non-zero length.
T: child-folder-count-from-disk:023,610
Each search command is restricted to my data partition T:

Code: Select all

T: empty: 
From a new user's point of view, someone who wants to reduce the number of empty folders to reduce folder-tree search time, the EMPTY: functions appears to be the safest. This will identify individual folders that contain no files of any sort (data files nor folder directory files) and seems to be a fool-proof way of tidying a partition.
Is that a correct interpretation?

T: childfoldercount: size:0 Still from a new user's point of view, this seems to offer a faster way of locating and then deleting entire folder trees that govern only empty files or folders.
Is that a correct interpretation?

The results of the first search are 74, of the second search 23. The 74 empty folders will always be found within the 23 folder trees.
Is that a correct interpretation?

The remaining three searches seem to this New User to be risky, if only because the result list can contain data files of non-zero length.
Is that a correct interpretation?

I invite speculation on the remaining three searches based solely on the counts displayed in the table. That is, what can you infer from the relative values of 79, 1646, and 23610?

Thanks, Chris
Last edited by ChrisGreaves on Sat Jun 29, 2024 3:22 pm, edited 1 time in total.
therube
Posts: 4879
Joined: Thu Sep 03, 2009 6:48 pm

Re: Understanding search for Empty FOLDERS

Post by therube »

I'm thinking that T: childfoldercount: size:0
should be showing a Count >= T: empty:
but in your case, it is not?

On my end (per Windows, Properties):
T: empty: - 7 files, 1209 folders
T: childfoldercount: size:0 - 994 files, 9263 folders


I always tend to check Properties to reinforce that what Everything returns conforms with what Windows says.
void
Developer
Posts: 16428
Joined: Fri Oct 16, 2009 11:31 pm

Re: Understanding search for Empty FOLDERS

Post by void »

From a new user's point of view, someone who wants to reduce the number of empty folders to reduce folder-tree search time, the EMPTY: functions appears to be the safest. This will identify individual folders that contain no files of any sort (data files nor folder directory files) and seems to be a fool-proof way of tidying a partition.
Is that a correct interpretation?
Yes.
I recommend selecting the empty folders and pressing Alt + Enter to show the Folders Properties dialog.
Double check the folders are really empty.

This might be necessary if you are excluding files from your index.


T: childfoldercount: size:0 Still from a new user's point of view, this seems to offer a faster way of locating and then deleting entire folder trees that govern only empty files or folders.
Is that a correct interpretation?
Yes, this will show folders with zero or more 'empty' files.
where there is at least one child folder.
Please be careful deleting empty files. Sometimes empty files can be important.

Omit the childfoldercount: and use the following to show empty folders too:
T: folder: size:0

This method might be confusing as it will show all nested zero-sized folders.
For example:
c:\empty-folder\foldera\folderb\folderc
c:\empty-folder\foldera\folderb
c:\empty-folder\foldera
c:\empty-folder

You can delete these and Everything will work out that you really only want to delete c:\empty-folder


The results of the first search are 74, of the second search 23. The 74 empty folders will always be found within the 23 folder trees.
Is that a correct interpretation?
No. This may miss some of those empty folders. (where there's a file with size directly in the folder - a parent of the empty folder)
Please try the following instead:
T: childfoldercount: !childsize:>0
T: childfoldercount: childsize:0


The remaining three searches seem to this New User to be risky, if only because the result list can contain data files of non-zero length.
Is that a correct interpretation?
Depends what the user is trying to do.
I don't recommend using these to delete folders.

T: childfilecount: size:0

will find folders where there is at least one child file.
All the child files must have a size of 0.
There might be descendant files, consider:
T: descendantfilecount: size:0


T: child-file-count-from-disk:0

will find the child count from disk.
It's very slow.
I recommend only using it with child-file-count:
For example:
T: child-file-count:0 child-file-count-from-disk:0
This will confirm there are no child files (which might be necessary if you are excluding files from your index)

T: child-folder-count-from-disk:0

Same as above, but for folders.


I invite speculation on the remaining three searches based solely on the counts displayed in the table. That is, what can you infer from the relative values of 79, 1646, and 23610?
T: child-file-count-from-disk:0

There might be descendant files (files in subfolders)
It will only list folders where there's no direct file children.

T: child-folder-count-from-disk:0


This one lists folders with no subfolders on disk.
The folder may contain files.
There will be a lot of these.



In Short,
To find empty folders in your index, search for:
empty:

To find empty folders on disk, search for:
empty: child-count-from-disk:0
NotNull
Posts: 5416
Joined: Wed May 24, 2017 9:22 pm

Re: Understanding search for Empty FOLDERS

Post by NotNull »

To skip over junctions (like C:\Users\AllUsers ==> C:\ProgramData) , add !attrib:L to themix:

Code: Select all

empty:   online:   !attrib:L   child-count-from-disk:0
(child-count-from-disk:0 cannot reportt on files that are off-line)
ChrisGreaves
Posts: 678
Joined: Wed Jan 05, 2022 9:29 pm

Re: Understanding search for Empty FOLDERS

Post by ChrisGreaves »

therube wrote: Wed Jun 26, 2024 7:35 pmI'm thinking that T: childfoldercount: size:0 should be showing a Count >= T: empty: but in your case, it is not?
“Shows parent folders” (my interpretation) is that only the roots of trees of empty folders will be reported; that made me think that 23 roots of trees could harbour 74 empty folders in total. I could be wrong.
I will digest Void’s response to better understand what these functions do.
On my end (per Windows, Properties): T: empty: - 7 files, 1209 folders T: childfoldercount: size:0 - 994 files, 9263 folders I always tend to check Properties to reinforce that what Everything returns conforms with what Windows says.
If by Windows Properties you suggest right-click, properties on the drive in the left-hand pane of Windows File Explorer then that does not (on any tab) show counts of empties. Likewise, Select-All on all root folders of a drive does not show counts of empties. I am running Win7 on this machine.

Thanks for my increased understanding!
Cheers, Chris
Last edited by ChrisGreaves on Fri Jun 28, 2024 10:51 am, edited 1 time in total.
ChrisGreaves
Posts: 678
Joined: Wed Jan 05, 2022 9:29 pm

Re: Understanding search for Empty FOLDERS

Post by ChrisGreaves »

void wrote: Thu Jun 27, 2024 12:43 amI recommend selecting the empty folders and pressing Alt + Enter to show the Folders Properties dialog. Double check the folders are really empty. This might be necessary if you are excluding files from your index.
Void thanks for confirming this point; it mirrors comments in the advanced search topics.
I see no “empties” in the folders dialog, as mentioned in my response to TheRube. I am back on a Win7 machine.
In terms of double-checking and the actual deletion, at this stage I am looking at data-gathering – assembling statistics on a specific drive to get an idea of whether there is value in cleanup on a drive. Checking, double-checking, and the specific method of deletion is an Action taken by the user, and is related to but separate from the creation of lists of folders-to-be-removed.
To illustrate this I might write a task which takes in a list of supposedly-empty folders and run it looking for any non-empty files.
Yes, this will show folders with zero or more 'empty' files.where there is at least one child folder.
Interesting. “folders with zero or more 'empty' files” is different from “folders with ONLY zero or more 'empty' (user-data) files”
Please be careful deleting empty files. Sometimes empty files can be important.
Agreed; especially on the C: drive. For that reason I am dealing only with the data partition T:
In a manual I would urge the New User NOT to experiment with their C: drive.
Marker/sentinel files are used by several applications, including some of my WordVBA applications.
Omit the childfoldercount: and use the following to show empty folders too: T: folder: size:0 This method might be confusing as it will show all nested zero-sized folders.
EmptyFolder_01.png
EmptyFolder_01.png (52.39 KiB) Viewed 1168 times
Thanks Void; more grist for the mill! I ran it on my data partition and received 158 results.
I will add this as an option to the table above.


No. This may miss some of those empty folders. (where there's a file with size directly in the folder - a parent of the empty folder) Please try the following instead: T: childfoldercount: childsize:0
EmptyFolder_02.png
EmptyFolder_02.png (46.99 KiB) Viewed 1168 times
Now I really AM confused.
As a new user I am expecting that “childsize:0” to return results that are in some small way related to seemingly useless folders.
The folder T:\Greaves contains an outpouring of work from around 1990 and onwards; 32 Gigabytes or so.
Your suggestion
childfilecount:1 childfoldercount:0 is OK for me – scads of folders each of which contains only one user-data file and as well contains no sub-folders.
I also read through child-folder-count.
I suspect that your example above (T: childfoldercount: childsize:0) is parsed as:-
(a) Only look in drive T:
(b) Establish a list of folders with a count of their child-folders (that is, folders that contain sub-folders)
(c) But from that list present ONLY those folders that contain a child (user data file) with a size of zero bytes.
I can’t reconcile that with my life’s work(grin) T:\Greaves.
The remaining three searches seem to this New User to be risky, if only because the result list can contain data files of non-zero length.
Is that a correct interpretation?
Depends what the user is trying to do.
The New User is trying to reduce the number of apparently useless folders and/or paths on the data partition. This user is new and is, sensibly, scared of deleting things that ought NOT be deleted. And it is no good saying "I’ve got a backup” because three months from now when an application fails, we have no idea that it fails because it is missing a sentinel file.
The new user is looking for a way to eliminate lots of truly empty folders.
In the old days one would program/hunt for leaves, folders, that contain no files (user-data or directory); delete those leaves, and then re-examine to discover leaves that NOW contain no files, repeat.
I don't recommend using these to delete folders.
Agreed. At this point in MY knowledge I’d recommend the use of “T: empty:” and leave it at that. Always, of course, suggesting that the user inspect a decent sample of the results before instituting the deletion process.
All of this, of course, draws us into an Indexes of Size and Count in terms of search speed and currency of data. I am most likely to recommend the use of the “…on-disk …” versions of functions. Takes longer to return results, but significantly less time than is taken to reinstall an application with its history!

Thanks Void; I shall plant this crop and return next year to plough a little deeper.
Cheers, Chris
ChrisGreaves
Posts: 678
Joined: Wed Jan 05, 2022 9:29 pm

Re: Understanding search for Empty FOLDERS

Post by ChrisGreaves »

NotNull wrote: Thu Jun 27, 2024 9:33 am To skip over junctions (like C:\Users\AllUsers ==> C:\ProgramData) , add !attrib:L to themix:

Code: Select all

empty:   online:   !attrib:L   child-count-from-disk:0
(child-count-from-disk:0 cannot reportt on files that are off-line)
Thanks NotNull.
I included my data drive and “T: empty: online: !attrib:L child-count-from-disk:0” returned (TaDah!) 74 items.
(d) I suspect that my T: pre-empts the online:
(e) I suspect that I have no hard-links on my data drive T:
(f) As mentioned in my response to Void, for the New User I would suggest the “…on-disk …” versions of functions
Cheers, Chris
therube
Posts: 4879
Joined: Thu Sep 03, 2009 6:48 pm

Re: Understanding search for Empty FOLDERS

Post by therube »

If by Windows Properties you suggest right-click, properties on the drive in the left-hand pane of Windows File Explorer then that does not (on any tab) show counts of empties. Likewise, Select-All on all root folders of a drive does not show counts of empties.
Select all (or whatever portion) of the results of "empty" directories you want, as found by Everything, from within Everything, then Alt+Enter (or right-click, Properties) on those.
Yes.
I recommend selecting the empty folders and pressing Alt + Enter to show the Folders Properties dialog.
Double check the folders are really empty.
ChrisGreaves
Posts: 678
Joined: Wed Jan 05, 2022 9:29 pm

Re: Understanding search for Empty FOLDERS

Post by ChrisGreaves »

therube wrote: Thu Jun 27, 2024 2:54 pmI recommend selecting the empty folders and pressing Alt + Enter to show the Folders Properties dialog.
EmptyFolder_04.png
EmptyFolder_04.png (91.24 KiB) Viewed 1149 times
Thanks therube.
Is the image above what you see?
I take it that the reported zero bytes (as in the image) indicates a gross total of zero bytes across the collection of selected folders?
Thanks, Chris
therube
Posts: 4879
Joined: Thu Sep 03, 2009 6:48 pm

Re: Understanding search for Empty FOLDERS

Post by therube »

Is the image above what you see?
Yes.
And in addition to 0 bytes, it also shows 0 Files & 73 Folders.
With that, you know there are no 0-byte files included in there.
I take it that the reported zero bytes (as in the image) indicates a gross total of zero bytes across the collection of selected folders?
Whatever you had selected (within Everything) when you did the Alt+Enter.

From your shot, I can't really tell.
You may have had 1 directory selected (that had 73 empty subdirectories within), or ??? directories selected...
ChrisGreaves
Posts: 678
Joined: Wed Jan 05, 2022 9:29 pm

Re: Understanding search for Empty FOLDERS

Post by ChrisGreaves »

therube wrote: Thu Jun 27, 2024 4:26 pm
Is the image above what you see?
Yes.
Thanks therube; I was looking for a string "empty folders" and "empty files"! :roll:
Cheers, Chris
void
Developer
Posts: 16428
Joined: Fri Oct 16, 2009 11:31 pm

Re: Understanding search for Empty FOLDERS

Post by void »

Now I really AM confused.
Changed:
T: childfoldercount: childsize:0
to:
T: childfoldercount: !childsize:>0

childsize: finds folders with a child file with the exact specified size.
I will add a total child size property for the next alpha update to avoid this confusion.
For now, use !childsize:>0
ChrisGreaves
Posts: 678
Joined: Wed Jan 05, 2022 9:29 pm

Re: Understanding search for Empty FOLDERS

Post by ChrisGreaves »

void wrote: Fri Jun 28, 2024 8:36 amT: childfoldercount: !childsize:>0
Thanks Void; (slaps self on forehead). I should have worked this out for myself.
If the search parameters were giving me the opposite of what I expected, I should have tried reversing/negating the search parameters.
Basic Logic.
childsize: finds folders with a child file with the exact specified size.
The critical part of this statement is the " a ".
I suspect that each of the 110 parent folders (reported in my screenshot) contained, somewhere in the tree, a folder which contained AN empty file.
That such folders contained other files, non-empty, didn't matter; if the parent folder contained at least one empty file, that satisfied the constraints.
Thanks again, Chris
Post Reply