Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that Windows explorer can colorize the NTFS compression state of a file, in both the regular and search views.

How can I specifically filter/search for files that are compressed or uncompressed on NTFS level?

Preferably a solution that works in Windows XP and higher (there are quite a few hardware devices for which no drivers are available for anything Vista and up).

Since Windows Search is too CPU intensive I'd like a solution without that as well.

share|improve this question
up vote 5 down vote accepted

Command-line interface

Windows XP doesn't provide a way to list compressed files out of the box, and even the advanced search methods aren't designed for such tasks. The command prompt comes to the rescue:

cd /d "C:\Some folder"
compact | findstr /c:" 1 C"

The cd command is simply used to navigate to the target directory. When the compact command is run without parameters it will list all files along with their compression details, if any. The output can be then filtered by redirecting it to findstr. For what is worth, this method should work even on Windows 2000.

Still, the output is quite verbose. To strip out the extra information some more work is required:

for /f "tokens=9,*" %A in ('"compact | findstr /c:" 1 C" "') do @dir /b "%A*%B" 2>nul

The command above will display compressed file names only. The dir command will help validating the file names to avoid false positives (e.g. those containing the string 1 C in their name).

Additional parameters you can use are:

  • /s Applies the command to all subfolders.
  • /a Displays hidden or system files.

Note that those parameters have to be used both for compact and dir commands, if needed.

To list uncompressed files, you can use the /v parameter of the findstr command to reverse the filter, and change the tokens value to 8 (that's because uncompressed files don't have the C marker, which affects the string tokenization).

Further reading

Advanced Query Syntax

Windows Search queries are specified in Advanced Query Syntax (AQS) which supports not only simple text searches but provides advanced property-based query operations as well.

Source: Windows Search - Advanced Query Syntax

AQS was first introduced with Windows Desktop Search, which was later improved and integrated into Windows Vista as Windows Search. You need to install it separately in earlier operating systems.

The following query will list all files which are have the archive attribute set and are compressed. It works in Windows XP, Vista and 7. It should also work in Windows 8.x, although I didn't test.


In English locales you can also use:


Here's a list of the most useful values:


In the example above I combined FILE_ATTRIBUTE_ARCHIVE and FILE_ATTRIBUTE_COMPRESSED: 32 + 2048 = 2080.

You can search any combinations by using the logical OR operator. For example, to search compressed files which are either read-only or not:

System.FileAttributes:(2080 OR 2081)

To invert the search results you can use the NOT operator:

System.FileAttributes:NOT(2080 OR 2081)

Further reading

share|improve this answer
Thanks. Too bad it is not supported in XP and Windows 2003 Server (most Windows XP drivers also work in Windows 2003 Server R2 which has EOL next year). I will create another answer (and not accept it) describing how to do the search on the command-line. – Jeroen Wiert Pluimers Mar 22 '14 at 18:16
@JeroenWiertPluimers In the original question you didn't specify the target operating system(s), so I only considered the newest ones. As for Windows XP, the most basic features were backported through Windows Search 4.0. – and31415 Mar 22 '14 at 18:24
Sorry for that, and Search is to CPU intensive that I'd never consider it. Will make a new edit to the question. – Jeroen Wiert Pluimers Mar 22 '14 at 18:26
@JeroenWiertPluimers I've updated my answer to include a command-line method without third party software. – and31415 Mar 22 '14 at 19:31
@JeroenWiertPluimers I did test it using a non-US installation; granted, I didn't test all languages. While I tried to make the command as locale-independent as possible, it might need to be adapted. Given your requirements, unless you known what's the target OS in advance and you're sure a solution like that would work as expected, a specialized third party tool like FindCompressed is probably the way to go, indeed. – and31415 Mar 24 '14 at 11:08

and31415 has posted a nice solution for Windows Explorer that works at least in Windows 7 and up (maybe in Vista, will check that later).

So for older Windows versions like XP and 2003, I've researched for a command-line solution that could generate a list of compressed or uncompressed files.

Compact: nice, but output is hard to parse

The first idea was using compact, which ships with Windows.

And indeed it can list files (enclose parameters in double quotes when they contain spaces):

compact [filemask] /a /s:[directoryname]

The format is easy to read for humans, but not easy to parse.

FindCompressed has a bug with long path names giving listings like this:

C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Help\en\DRS41\wwhelp\wwhimpl\common\htmlinit3.htm
C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Help\en\DRS41\wwhelp\wwhimpl\common\htmlpagenav.htm
C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Help\en\DRS41\wwhelp\wwhimpl\common\html\imagessplash.jpg
C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Help\en\DRS41\wwhelp\wwhimpl\common\imagestoolsbg.gif
C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Help\en\DRS41\wwhelp\wwhimpl\common\scriptsunidata.js

So it cuts parts of the files or directories when the names get too long.

#FindCompressed: nice, output first/last line needs to be stripped

Exodus Development wrote the command-line tool FindCompressed. Without parameters, it finds compressed files. With the -su parameter, it finds uncompressed files. Enclose [directoryname] in double quotes when it contains spaces.

FindCompressed.exe -su [directoryname]

FindCompressed has one drawback: it always starts output with this line where # is [directoryname]:

Recursive search of compact #.

and ends with a line like this:

Found # uncompressed files in # items examined. 

The lines between those contain a full path to the uncompressed or compressed filename.
That is easy to parse.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .