Friday, 6 September 2013

Remove Empty Folders in Windows

Many people tend to install and uninstall a lot of software on a regular basis. They even record videos and take amazing photos in their smartphones thanks to the increasing power of smartphone cameras. In such conditions, it is not very uncommon to create unused directories or empty directories. Though these directories do not take much space(unless you count some temp or database files), they often create an inconvenience. 

I have been using an amazing tool called RED, which stands for Remove Empty Directories. I have started using the command line recently, and I searched around to see if I can use a command that recursively deletes empty directories. 


I found the following solution in an answer found on the website, Superuser.

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


The command deleted recursive empty directories. For people who are unaware of how to run the command:

1.Open Notepad
2.Paste the command(Do yourself a favor and don't try to type in, unless you are very sure).
3.Save the file as "Any_Name.bat" (the double quotes and the .bat extension are very important).
4.Copy this file to the directory where you want to delete empty directories.
5.Double click to run the File.

Voila! And, you are done....

No comments:

Post a Comment