Have you came across a scenario whereby you want to delete all files in main and sub folders while maintaining folder tree structure? By default, Windows doesn’t provide such a feature and you need to do it in a very manual way, by going to each of the folders and highlight all the files you want to delete followed by a Delete button pressed. You need to repeat the same action by going to each of the sub folders until all files have been deleted. All these steps could be very time consuming and painful especially when the folder tree structure becomes more complicated. Now with this simple utility, you can delete all files in main and its sub folders while maintaining the folder tree structure with only few steps.



This feature can be enabled in right click folder menu by editing the registry key. Just follow instructions as mentioned below and you are done:

1) Go to Start -> Run, then type ‘regedit’ and press enter
2) Locate to HKEY_CLASSES_ROOT\Directory\shell
3) Right click on ‘shell’ folder and choose New -> Key, name the new sub key as ‘Empty Folder Contents’.
4) Right click on ‘Empty Folder Contents’ and choose New -> Key, name the sub key as ‘Command’.
5) Under the ‘Command’ sub key, double click on ‘Default’ as located at right panel. A small Edit String window will be pop up, then enter this value: cmd /c “cd /d %1 && del /s /f /q *.*”
6) Click OK button to save the setting.

Once this is done, right clicking on the folder (that you intend to delete the contents) and its sub folder contents, you will see ‘Empty Folder Contents’ has been added in the context menu. Just click on it and all the files in this folder as well as sub folders will be deleted without disturbing the original folder tree structure.

The empty folder contents trick also works in Windows Vista.

Related Posts