Windows: Delete All Files in a Directory Except Specified Ones

Print Page

Delete All Except is a free portable application that helps you quickly delete all files in a directory (including subdirectories) and keep only those that you want.
Delete All Except
This program can be handy when you have a folder with many unwanted files. Instead of going through one by one, you could use it to quickly clean up the folder to keep only those that you actually need.

How to Use

To use the program, select the folder to process in the folder textbox and specify the files you want to keep in the Filters textbox. You can specify file name and file extension as filters. For example, add file.xls as filter to keep only that file, or to keep all Excel files use *.xls as the filter. Multiple filters are possible, and you can mix them as well. Just remember to add a comma between each filter while using multiple.

After specifying your filter, click on Preview button to preview files that would be affected. In the new window that opens, you can see the files that would be deleted at the top, and below them are those that would be kept. If it isn’t what you want, close the dialog to reconfigure the filters, or else click on Delete button to start deleting the files.
Delete All Except preview

Delete All Except works on both 32-bit and 64-bit version of Windows operating system.

Download

Delete All Files Except One from Command Line

You can also use command line methods to accomplish this. To do so, browse to the folder you want to process, then run the below command:

FOR %I IN (*) DO IF NOT %I == file.xls DEL %I

This will delete all files in the directory except file.xls.