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.
Remove empty folders using "for" and "rd" commands. You enumerate and delete all empty folders using CMD internal commands for and rd. This is specific and deletes only the empty ones. Press and hold on the Shift key.
Use the rmdir command to remove the directory, specified by the Directory parameter, from the system. The directory must be empty (it can contain only .
To delete folders in Windows 10 with CMD you have to use the rmdir command. This command will remove all folders including the subfolders and files in them.
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.
A simpler way is to do xcopy to make a copy of the entire directory structure using /s switch. help for /s says Copies directories and subdirectories except empty ones.
xcopy dirA dirB /S
where dirA is source with Empty folders. DirB will be the copy without empty folders
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With