CodShot
Batch Public

Delete Empty Folders

A Windows CMD snippet that removes empty folders under the current directory.

#cmd #windows #cleanup #folders
Batch
@echo off

for /f "delims=" %%D in ('dir /ad /b /s ^| sort /r') do (
    rd "%%D" 2>nul
)

echo Empty folders removed.
pause

Notes

This removes only empty folders. Test it in a safe directory first.

Snippet actions

CodShot user
CodShot user
Updated: 2026-06-03 14:05
Public snippets
0
Forks
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support