- 1. Intro
- 2. How to βinstallβ the utility
- a. Automatically deleting all empty folders
- OPTION A
- OPTION B
- b. Creating the mother-of-all shortcuts
1. Intro
This is a fun one. I found a utility, not long ago, to delete all the empty folders and subfolders within a directory. I think it's super useful to clean up those complicated project folder structures that end up with more empty folders than used ones. Other times, it's just overall cleanup when necessary.
The tool in question is aptly called Delempty, and was created by Skrommel with AutoHotKey. With it you can open certain folders and it will scan the items inside, letting you pick those with 0 files or 0 bytes. This alone is a great (and safe!) way to get rid of those pesky files. If you just want the tool this form, get it here:
HOWEVER, we can s p i c e things up a bit and make this tool automatic, and also give it a powerful shortcut that will let us right click anywhere and use the tool in the current folder and subfolders.
2. How to βinstallβ the utility
a. Automatically deleting all empty folders
What we need to do now, is take this utility and configure it to do what we want, automatically.
For this, we can use a .bat file, and point it to the Delempty.exe tool, along with some indications on what we want it to do.
I've created two separate zip files containing different settings for the tool (click to download):
- Will delete empty folders and directories
- Will include subfolders
- Will list all folders about to be deleted
- Will ask for confirmation before deleting
- Will delete empty folders and directories
- Will include subfolders
- Will not list all folders to be deleted
- Will delete without confirmation
Personally, I use Option B. But I'm also a maniac, and I think you should start with Option B just to play around. To switch options just copy replace one .bat file with the other.
You can extract the zip file, and place the folder on your C:/Program Files directory, so that it will live here:
The way I've set it up, the Delete Empty Folders.bat script will look for the Delempty.exe tool in this directory, tell it which folder you're pointing at, and execute it with some options written in the form of letters at the end of the script. Nothing that you need to know, but it's a pretty basic setup so if you ever dig in, you'll understand right away.
b. Creating the mother-of-all shortcuts
In order to create this shortcut so that we can execute the tool by right clicking inside any folder, we're going to add it through the Windows Registry editor. Press the Win+R key, and type regedit on the small window that pop up. Then, press enter.
Inside here, you want to navigate to the following folder:
Then, right click on the shell folder to create a New Key (looks like a folder), and call it "Delete Empty Folders".
Once again, right click on the new Delete Empty Folders key you just created, and create a new key underneath, and call it "command".
Click on the command key, and on the window to the right you should see a default key. Double click on it, and type (or copy/paste) the following as the value:
Hit OK and you can right away check in any folder if the shortcut is there by right clicking! π
It works a bit differently if you're not the admin user in the computer, so I'll leave this link to some broader instructions on how to make this work.