Identifying compressed files from command line

  • Thread starter Thread starter Paul Smith
  • Start date Start date
P

Paul Smith

Does anyone know of a way to search for compressed files
via the command line? I've looked under different
attributes but haven't found anything.
 
From the command prompt do compact /? for options:

Displays or alters the compression of files on NTFS partitions.

COMPACT [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [filename [...]]

/C Compresses the specified files. Directories will be marked
so that files added afterward will be compressed.
/U Uncompresses the specified files. Directories will be marked
so that files added afterward will not be compressed.
/S Performs the specified operation on files in the given
directory and all subdirectories. Default "dir" is the
current directory.
/A Displays files with the hidden or system attributes. These
files are omitted by default.
/I Continues performing the specified operation even after errors
have occurred. By default, COMPACT stops when an error is
encountered.
/F Forces the compress operation on all specified files, even
those which are already compressed. Already-compressed files
are skipped by default.
/Q Reports only the most essential information.
filename Specifies a pattern, file, or directory.

Used without parameters, COMPACT displays the compression state of
the current directory and any files it contains. You may use multiple
filenames and wildcards. You must put spaces between multiple
parameters.





Joep

--
D I Y D a t a R e c o v e r y . N L - Data & Disaster Recovery Tools

http://www.diydatarecovery.nl
http://www.diydatarecovery.com

Please include previous correspondence!

DiskPatch - MBR, Partition, boot sector repair and recovery.
iRecover - FAT, FAT32 and NTFS data recovery.
MBRtool - Freeware MBR backup and restore.
 
Hi Paul,

I am not a cmdprompt expert but I do not think that there is a cmd prompt command
that can be used to search for files with the compressed attribute. Perhaps the
following method, posted by MVP Scripting Expert Torgeir Bakken, would meet your
needs though.

Google Groups URL to original thread:
http://www.google.com/groups?&[email protected]

----- Begin Original Message -----
From: "Torgeir Bakken (MVP)" <[email protected]>
Newsgroups: microsoft.public.win2000.file_system
Sent: Monday, February 24, 2003 09:10 PM
Subject: Re: How can I list every file in an NTFS FS that has been compresed ?

Easy with WMI, put the script below in a .vbs file and run it in a command prompt
with cscript.exe:

sComputer = "." ' use "." for local computer

Set oWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")

' Getting only the Name property from the files found
sWQL = "select Name from cim_datafile where Drive='c:'" _
& "AND Compressed=True"

Set oResult = oWMI.ExecQuery(sWQL,,48)
For Each oFile In oResult
WScript.Echo oFile.Name
Next

----- End Original Message -----

Note 1: This script is Memory and time intensive.

Note 2: As written the script searches the C:\ Drive. To search a different drive
replace the c in the following line with the desired drive letter: Drive='c:'"

Note 3: To redirect the output to a text file follow this example:

- Copy and paste Torgeir's script into notepad and save it as compressedfiles.vbs
- Open the command prompt (cmd.exe) to the directory where you saved
compressedfiles.vbs
- Use the following command to redirect the output to the text file named
compressed.txt:

cscript compressedfiles.vbs > compressed.txt

Note 4: If you have any questions about scripting I suggest that you post in an
appropriate newsgroup such as:

microsoft.public.win2000.cmdprompt.admin
microsoft.public.scripting.vbscript

--
Carrie Garth, Microsoft MVP for Windows 2000
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- c x g

: "Paul Smith" <Paul_Smith AT millipore DOT com>
: Wrote in message : Sent: Tuesday, October 07, 2003 07:50 AM
:
: Does anyone know of a way to search for compressed files
: via the command line? I've looked under different
: attributes but haven't found anything.
 
Back
Top