Compact command
The compact command is used to compress files to improve transferability, or uncompress them so that they are viewable.
Availability
Compact is an external command available for the following Microsoft operating systems as compact.exe.
Compact syntax
Windows 10 and Windows 11 syntax
Displays or alters the compression of files on NTFS partitions.
COMPACT [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [/EXE[:algorithm]] [/CompactOs[:option] [/WinDir:dir]] [file name [...]]
/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 are not 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 already compressed. Already-compressed files are skipped by default. |
/Q | Reports only the most essential information. |
/EXE | Use compression optimized 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 system's compression state. Supported options are: query - Query the system's compact state. always - Compress all OS binaries and set the system state to compact, which remains unless the administrator changes it. never - Uncompress all OS binaries and set the system state to non compact, which remains unless the administrator changes it. |
/WinDir | Used with /CompactOs:query, when querying the offline OS. Specifies the directory where Windows is installed. |
file name | 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 file names and wildcards. You must put spaces between multiple parameters.
MS-DOS, Windows 2000, Windows XP, Windows Vista, Windows 7, and Windows 8 syntax
Displays or alters the compression of files on NTFS partitions.
COMPACT [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [file name [...]]
/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 are not 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 already compressed. Already-compressed files are skipped by default. |
/Q | Reports only the most essential information. |
file name | 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 file names and wildcards. You must put spaces between multiple parameters.
Compact examples
compact
Display all the files in the current directory and their compact status.
compact file.txt
Display the compact status of the file.txt file.
compact file.txt /C
Compacts the file.txt file.