was successfully added to your cart.

Applying a Custom Filter in an Open File Dialog

By April 29, 2009 January 3rd, 2011 Tips & Tricks

What I’m going to cover now is a pretty minor feature of Windows. I would of skipped this article, but I encountered a few people that never heard of this trick. I’ve personally found it useful in scenarios where I was working with custom file extensions… for example, I knew that a particular file with the uncommon extension “.def” could be opened in Microsoft Access.  The file extension “.def” is not typically associated with Microsoft Access, but I knew it was a valid file.

To explain how the feature works, consider your typical, everyday “Open File” dialog:

A an example of a File-Open dialog showing an active filter.

An example of a typical "Open File" dialog - from uTorrent

In this example, the dialog wants you to select a “.torrent” file by default. Because this is the active filter, you only see files that have a “.torrent” extension in the folders you view.  What if you had a file with a “.abc” extension – and you knew it was a valid torrent file,  just with a different extension? If you wanted to select it, you’d have to change the filter dropdown to “All Files”, and then find it that way. If you had a lot of files in the same folder as the “.abc” file, you’d have to look through the list to find the one you want.

Wouldn’t it be great if you could simply filter for “.abc” files, even though the dropdown doesn’t have it as an option? Guess what… you can.

Simply type:

*.abc

in the “File name” textbox, and click press Enter.

This is the result:

A File-Open dialog with a custom filter applied.

Notice how the “.torrent” file is no longer visible? This is because we just applied a custom filter, one that told the dialog to only display the files having an extension of “.abc”.  This little trick can be useful when you’re dealing with lots of a files –  it can reduce the clutter and make it easy to find something specific.

Here’s an interesting detail: if you take another look at the filter dropdown, as show in the screenshots, you’ll notice that the filter itself is shown in the name of the dropdown choice. Consider the “Torrents” filter from the above screenshot:

Torrents (*.torrent)

The portion within the parentheses (green font) is the filter that Windows is internally applying when you select the dropdown. All we’re really doing by typing the filter directly in the “File name” textbox is bypassing the limited options in the user interface, likely using the same approach as Windows would had the option been available as a dropdown.