How to delete empty folders using windows command prompt?

DEVOPS picture DEVOPS · Oct 20, 2011 · Viewed 145.4k times · Source

I need to delete all empty folders from my application folder using windows command prompt?

How can I create a bat file like that?

Please help me.

Answer

Varun Sharma picture Varun Sharma · May 9, 2015

You can use the ROBOCOPY command. It is very simple and can also be used to delete empty folders inside large hierarchy.

ROBOCOPY folder1 folder1 /S /MOVE

Here both source and destination are folder1, as you only need to delete empty folders, instead of moving other(required) files to different folder. /S option is to skip copying(moving - in the above case) empty folders. It is also faster as the files are moved inside the same drive.