How to find all empty directories in Windows? For Unix there exists find. So there is an out of the box solution. What is the best solution using Windows?
I found several solutions so far:
This Powershell snippet below will search through C:\whatever and return the empty subdirectories
$a = Get-ChildItem C:\whatever -recurse | Where-Object {$_.PSIsContainer -eq $True}
$a | Where-Object {$_.GetFiles().Count -eq 0} | Select-Object FullName
WARNING: The above will ALSO return all directories that contain subdirectories (but no files)!
This python code below will list all empty subdirectories
import os;
folder = r"C:\whatever";
for path, dirs, files in os.walk(folder):
if (dirs == files): print path