Scan and Delete empty folders
Wednesday, September 20, 2006
It is a very simple Windows shell script which will remove empty folders (directories) from filesystem.
Surprisingly, I have not found any inbuilt command under Windows to clean up file systems by removing unneeded empty directories. I often have such empty folders after restructuring a project archive. Although they don't take up much space, they are untidy and give spurious hits in searches. Also one become freaky when you see a empty folder without any contents after travling around 7 folders deep. So I wrote this script.
How to use RemoveEmptyFolders.bat script (Bit manual, but works!)- Copy the script in folder, which empty sub-folders should be deleted. Run the script. Script will create a bat file named 'EMPTIES.BAT' which will containes list of sub-folders.
- Now open any text editor (I use Editplus) and add prefix RM (Delete command) before each line.
- Note that If your path contains any spaces then put the path in (") double inverted comma.
Sample edited EMPTIES.BAT fileRD "C:\Documents and Settings\Sandesh\trophies"
RD "C:\Documents and Settings\Sandesh\trophies\XYZ"
RD "C:\Documents and Settings\Sandesh\trophies\ABC"Download RemoveEmptyFolders.bat [Disclaimer: This is a freeware script, Use it at your own risk. Author will not responsible for any loses due to using this RemoveEmptyFolders.bat script.]
Propagate!
These icons link to social bookmarking sites where readers can share and discover new web pages.
Posted by Sandesh
Email this!
5 Comments on 'Scan and Delete empty folders':
More utility script based on yours
for /F %%i IN ('"DIR /AD/B/S | SORT /R"') DO rmdir /q %%i
/Alexander
By Anonymous, at 4:39 pm, April 14, 2008
for /F "tokens=*" %%i IN ('"DIR /AD/B/S | SORT /R"') DO rmdir /q "%%i"
By Anonymous, at 7:30 pm, September 02, 2008
for /F "tokens=*" %%i IN ('"DIR /AD/B/S | SORT /R"') DO rmdir /q "%%i"
By Anonymous, at 7:33 pm, September 02, 2008
By Sandesh, at 7:42 pm, September 02, 2008
By Nikhil, at 12:17 pm, February 11, 2009
Post a Comment