Search for Empty folders in Windows

Wheresatom

[H]ard|Gawd
Joined
Mar 20, 2007
Messages
1,390
As the company I work for grows it was decided that we needed to move to a "unified file structure" to keep people from organizing folders how they like. So, most project directories are locked down pretty tightly but at the outset of the project a number of predetermined folders are created from a template. Because of that, and the fact that you cannot delete any of the folders that are necessary, there are tons of empty folders in most project directories. Is there an easy way to determine that number exactly? I am thinking in many projects that number is in the range of 50-75 empty folders but I'd rather not check it the hard way in too many projects.
 
I tried an empty folder deleter. When I get home I can see if I still have it and give you the name of the program which might do the job you want to do.
 
A powershell script can accomplish this pretty easily, if you're comfortable working with the command line.
Code:
(dir f:\ -recurse -ea 0)|where{$_.psiscontainer -eq $true}|where{(dir ($_.fullname)) -eq $null}|foreach{$_.fullname}

That will list them.

Code:
(dir f:\ -recurse -ea 0)|where{$_.psiscontainer -eq $true}|where{(dir ($_.fullname)) -eq $null}|measure

Will count them.

Just replace the "F:\" in "(dir f:\)" with your drive or folder that you want to list empty folders from.
You can do a lot of other things with a little work, like count the empty folders in a folder, or delete the empty folders, or output to .xml or .html with custom formatting, print them, email them, etc.
 
Last edited:
Back
Top