How To Delete/Empty Folder Contents Easily Preserving Folder Structure

Usually the system can only completely delete complicated folder structures. But you want to preserve the structure and delete only the data files in it. However, opening and clearing out every single folder can be quite a painful and time taking task. A small registry edit can do this job for you. Preferably, you should define a context command so that you find the process easy. This will create a context menu item which lets you delete contents of folders without affecting the folder structure.

delete folder contents without deleting folder structure

To add the context menu item, do this,

  • Open the registry by going to ‘Start > Run’ and type ‘regedit’.
  • In the registry, navigate to the ‘HKEY_ CLASSES_ROOT\Directory\shell’ key.
  • Right click on ‘shell’ and create the ‘Empty Folder Contents’ sub key with ‘New > Key’.
  • Then create the ‘command’ sub key in the same way.
  • Open ‘Default’ by right-clicking on it in the right hand window of ‘command’ and fill it with the following:  ‘cmd /c “cd /d %1 && del /s /f /q *.*’.
  • The new command ‘Empty folder contents’ will be displayed in the context menu for folders immediately after you close the registry.

Now whenever you need to empty  the contents of the particular folder, just right click on the folder and choose ‘Empty Folder Contents’ from the context menu and leave the rest to Windows.


Leave a Reply