- Worldstart's Tech Tips And Computer Help - http://www.worldstart.com -

Empty Just Folder Contents

Posted By On February 4, 2010 @ 11:27 AM In Desktop Enhancement | No Comments


How many times has something as simple as deleting files wasted your time? Windows file management has progressed much since the old days of MS-DOS, but it’s still far from perfect.

Deleting files is easy in Windows; you just select the folder where the files are stored and press “delete”. But what if you had to delete a whole bunch of files while maintaining the folder structure?

The usual way involves going into each folder, selecting the files and pressing delete. Then you repeat the process for every folder you want to empty of its contents.
This isn’t a problem if you have two or three folders to empty, but if you have a folder structure made up of tens or hundreds of folders, with maybe one or two files in each; it quickly turns into a big time waster.

Luckily there is a solution to this problem. By tweaking the Windows Registry you can add an “Empty folder contents” command to the right-click context menu of your folders.

With one mouse click you could delete all the files in that folder as well as files in any subfolders, while maintaining the folder tree structure.

Warning: Before we go any further, I’d like to point out that messing around with the Windows Registry is not meant for beginners. Editing the Registry directly can have serious, unexpected consequences that can prevent the system from starting and require that you reinstall Windows. If you feel that you do not understand or are unable to perform the steps below, please seek expert advice.

Also, I recommend backing up the Registry before attempting any modification.

To back up the entire Registry in any Windows version, open the Registry editor. Type regedit in the search bar of the start menu, right click on regedit.exe and select Run as administrator. Click on the My Computer (or Computer for Vista and 7) registry key at the top and select File in the top left corner of the window. In the File menu select Export…, give it a name like “registry backup” and choose a safe location to save your file.

If something does go wrong while editing, you can restore the Registry by navigating to where you saved the .reg file and simply double click on it.

Now that you have backed up the Registry you can proceed with the rest of the article.

To change a Registry setting we must first open the Registry Editor. Just follow the same steps above: In Windows XP click Start>Run and type “regedit” then click OK. For Vista and 7, click Start and type “regedit” in the Search Box and pres Enter.

image

The Registry Editor will now open.

The setting we need to change is located in the Registry structure, at the following address:
HKEY_CLASSES_ROOT\Directory\shell

Click the plus sign next to HKEY_CLASSES_ROOT and scroll down the list until you locate Directory.

Then click the plus sign next to Directory to reveal shell.

Right click the shell key and from the menu select New and then click on Key.

Type Empty Folder Contents and press Enter from the keyboard.

Right click on Empty Folder Contents and from the menu select New and then click on Key.
Type Command and press Enter from the keyboard.

image

Left click on the Command key. Locate (Default) at the top of the right window panel and right click on it.

In the menu select Modify and an Edit String dialog box will appear.

Carefully type: cmd /c “cd /d %1 && del /s /f /q *.*” verbatim in the Value Data field and click OK.

Please type the command rather than copying it from above or it may not work.

Now close the Registry Editor by clicking File and then Exit from the menu.

image

You will see the new Empty Folder Contents command in the right click contextual menu of any folder.

Warning! Clicking the Empty Folder Contents command will delete all the files in the folder and any subfolders without asking for a confirmation. It will also bypass sending the deleted files to the Recycle Bin. Instead it will remove the files directly. Use this command at your own risk.

~Cosmin Ursachi

Article printed from Worldstart's Tech Tips And Computer Help: http://www.worldstart.com

URL to article: http://www.worldstart.com/empty-just-folder-contents/