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.
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.
It will be worked fine. This is best way to delete old files and remove empty directories recursively. following .bat file is,
The placeholders needs to be replaced as follows (without the quotation marks):
The script has been successfully tested under Windows 7 and Windows Server 2003.
from: http://blogs.msdn.com/b/oldnewthing/archive/2008/04/17/8399914.aspx
Of course I'd test it first without deleting before I do that command. Also, here's a modded version from the comments that includes folders with spaces:
P.S. there are more comments in the blog post that might help you out so be sure to read those too before you try this out
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.
where dirA is source with Empty folders. DirB will be the copy without empty folders
You don't need usebackq:
well, just a quick and dirty suggestion for simple 1-level directory structure without spaces, [edit] and for directories containing only ONE type of files that I found useful (at some point from http://www.pcreview.co.uk/forums/can-check-if-folder-empty-bat-file-t1468868.html):
/ad : shows only directory entries
/b : use bare format (just names)
[edit] using plain asterisk to check for ANY file (%a\* above) won't work, thanks for correction
therefore, deleting would be: