At times, you may be in a situation where in you want to delete or empty content, within folder and subfolders within it and at the same time, you want to retain the Folder / Directory structure. If the folder structure is small, you can do this task manually, but it can be a real pain if you have a deep folder/directory structure.

This simple registry hack will make it very easy for you to empty the content of the folders and sub-folders. A new context menu item will be added to the context menu, when selected will delete all the content.

Note: If you are not comfortable editing registry values, read this post. It adds the same feature without you dabbling with the registry editors.

Note: You should be very careful when deciding which folder to empty, as the files deleted using this method cannot be recovered as they will be permanently deleted.

1> Go to ‘Start –> Run –> regedit
2> Navigate to ‘HKEY_ CLASSES_ROOT\Directory\shell‘ key.
3> Right click on the key ‘Shell‘ and create a sub-key and name it as ‘Empty Folder And SubFolder Contents
4> Create a sub-key for ‘Empty Folder And SubFolder Contents‘ and name it as ‘command
5> When you select ‘command’ sub-key, you’ll see Default value data in the right pane.
6> Double click on it and enter

cmd /c “cd /d %1 && del /s /f /q *.*”

7> Save the new settings by clicking the OK button and exit registry editor.

Now your contenxt menu will have a new option ‘Empty Folder And SubFolder Contents‘, which will clean up all content for you, but will leave the directory structre in tact !