COMPACT

Display or alter the compression of files on NTFS partitions.

Syntax
      COMPACT [/C | /U] [/S[:dir]] [/A] [ /I] [/F] [/Q] [/EXE[:algorithm]]
         [/CompactOs[:option] [/WinDir:dir] [filename [...]]

Key    
   /C        Compress the specified files.
             Directories will be marked so that files added afterward will be compressed.

   /U        Uncompress the specified files.
             Directories will be marked so that files added afterward will not be compressed.

   /S        Perform the specified operation on files in the given directory and all subdirectories.
             The default "dir" is the current directory.

   /A        Display files with the hidden or system attributes.
             By default hidden or system files are not displayed in the query output.

   /I        Continue performing the specified operation even after errors have occurred.
             By default, COMPACT will stop when an error is encountered.

   /F        Force the compress operation on all specified files, even those which are already
             compressed.  Already-compressed files are skipped by default.

   /Q        Report only the most essential information.

   /EXE      Use compression optimised for executable files which are read frequently and not modified,
             Supported algorithms are:
               XPRESS4K (fastest) default
               XPRESS8K
               XPRESS16K
               LZX   (most compact)

   /CompactOs  Set or query the systems compression state.
             Supported options are:
               query  - Query the systems compact state.
               always - Compress all OS binaries and set the system state to non-compact.
               never  - Uncompress all OS binaries and set the system state to compact which remains
                        unless an administrator changes it.

   /WinDir   Used with /CompactOs:query, when querying the offline OS. Specifies the directory where
             Windows is installed.

   filename  Specifies a pattern, file, or directory.

Used without parameters, COMPACT displays the compression state of the current directory and/or any files it contains.

Turning ON compression for a folder willl compress all the files within and any future files added.

Turning OFF compression for a folder willl not compress any future files added, existing files will be unchanged unless /S is specified.

Examples

Query the compression status of a file or folder:

compress C:\demo\*.txt
compress C:\demo\

Turn on compression for the C:\demo\ folder including all sub-folders:

compress /c /s:C:\demo\

Turn off compression for the C:\demo\ folder including all sub-folders:

compress /u /s:C:\demo\

Turn off compression for all .txt files within the C:\demo\ folder:

compress /u C:\demo\*.txt

“The truth includes all, and is compact just as much as space is compact" ~ Walt Whitman (Leaves of Grass)

Related commands

ATTRIB - Change file attributes.
IEXPRESS - Create a self extracting ZIP file archive.
MAKECAB - Create .CAB files.
TAR - Store, list or extract files in an archive.
Compress-Archive - PowerShell.


 
Copyright © 1999-2024 SS64.com
Some rights reserved