Tag Archives: dos

Delete Empty Folders

I recently found that I had a lot of empty folders in my MP3 folder after a wayward ripping session. So I whipped up this quick DOS one-liner to remove all empty folders.

From a command prompt, just change to the folder containing all the empty folders and enter the following:

FOR /f "tokens=*" %G IN ('dir /ad /b /s') DO rd /q "%G"

The command "rd /q" will be executed on every folder, but "rd" only deletes empty folders -- "rd" does not delete non-empty folders.