Command line to delete empty folders Windows 11, 10, ....!
If you want to delete empty folders via command line, here is the command for all Microsoft's Windows 11, 10, ... Desktop and MS Server OS!
1. Hold down the Shift key, right-click a folder
2. Click here Open Command Prompt (or Powershell, or Terminal APP)
(the Command Prompt is open on the current folder)
3. When you are in the Command Prompt in the desired Directory, run the following command line:
for /f "delims=" %d in ('dir /s /b /ad ^| sort /r') do rd "%d"
Note:
You need to make sure that you are running the following command from the exact path of the parent folder where you need to find and remove empty subfolders.
The range of commands and the options are the main difference between PowerShell and the command prompt on Windows 11, 10, and MS Server OS The MS PowerShell