Tuesday, 7 February 2023

Recursively delete empty directories in Windows

 

Recursively delete empty directories in Windows

 

 

You can use Remove Empty Directories utility.

Alternatively you can use this one-liner batch file (from DownloadSquad):

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

(if used inside a batch file, replace %d with %%d)

This works because rd will not remove a directory that contains files.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive