I need to find all compressed files/folders regardless of file format on a Windows Server 2003 machine. Search options do not provide this capability.

Is there a way to list/view all compressed files?

Perhaps, this can be done by PowerShell using file/folder attributes and put into a txt file with file location.


Under compressed files/folders - I mean files which appear in blue color in Explorer after changing file/folder attribute.

enter image description here

  • Can you define what you mean by compressed files? Do you mean all .zip, .rar, .7z, .tar.gz, .etc? – Grumpy Nov 27 '12 at 12:25
  • I mean files compressed with the means of Windows, the ones which appear in blue color in Explorer. – Volodymyr Molodets Nov 27 '12 at 12:26

The compressed indicator is stored in the "attributes" property. This Powershell will report compressed files.

gci -r C:\search\path | where {$_.attributes -match "compressed"} | foreach { $_.fullname }

-- Begin Edit

The file size is stored in the length property, which is in bytes. You can use whats called a "calculated property" to display the size in kb,mb,gb, etc.

$col1 = @{label="Size";Expression={$_.length/1mb};FormatString="0.0";alignment="right"}
$col2 = @{label="Fullname";Expression={$_.fullname};alignment="left"}
gci -r | where {$_.attributes -match "compressed"} | ft $col1,$col2 -autosize

If you want only larger files, say greater than 1MB

gci -r | where {$_.attributes -match "compressed" -AND $_.length -gt 1mb} | ft $col1,$col2 -autosize

Folder size is also possible, a slightly different beast. Just try google'ing "powershell folder size" lots of posts on how to do that. There are also many free tools (windirstat) to report folder sizes.

| improve this answer | |
  • 1
    Perfect! In addition to this, can I somehow get size for each folder/file in the output? – Volodymyr Molodets Nov 27 '12 at 17:38
  • Incidentally, both 'dir' and 'ls' are actually just aliases for 'gci' and might be easier to remember. Also, I'll add another vote for WinDirStat. It's the perfect tool for viewing file/folder sizes. – ColdCold Oct 27 '16 at 1:33

The definition is rather vague as "compressed file" can mean a wide range of files. You have your normal .zip .tar .7z etc. You also have .cab files although I'm not certain how common they are nowdays.

AFAIK, there is no easy way to find compressed files per se. You need to simply define what filetypes you want to find and use the DOS-command dir.

At the root prompt type

dir *.zip *.rar *.7z *.tar /s >> output_file.txt

This will list all the filetypes in all subdirectories and store the output in the file output_file.txt. Then you can go through the "log" and look for what you want.

For more in depth information on DIR - http://www.computerhope.com/dirhlp.htm

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.