# compact

Displays or alters the compression of files or directories on NTFS partitions. If used without parameters, compact displays the compression state of the current directory and any files it contains.

## Syntax

``````compact [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [/EXE[:algorithm]] [/CompactOs[:option] [/windir:dir]] [filename [...]]
``````

### Parameters

Parameter Description
/c Compresses the specified directory or file. Directories are marked so any files added afterwards are compressed, unless the /EXE parameter is specified.
/u Uncompresses the specified directory or file. Directories are marked so any files added afterwards aren't compressed. If the /EXE parameter is specified, only files compressed as executables are uncompressed; if you don't specify the /EXE parameter, only NTFS compressed files are uncompressed.
/s`[:<dir>]` Performs the chosen operation on files in the specified directory and all subdirectories. By default, the current directory is used as the `<dir>` value.
/a Displays hidden or system files. By default, these files aren't included.
/i Continues performing the specified operation, ignoring errors. By default, this command stops when an error is encountered.
/f Forces compression or uncompression of the specified directory or file. Already-compressed files are skipped by default. The /f parameter is used in the case of a file that was partly compressed when the operation was interrupted by a system crash. To force the file to be compressed in its entirety, use the /c and /f parameters and specify the partially compressed file.
/q Reports only the most essential information.
/EXE Uses compression optimized for executable files that are read frequently, but not modified. Supported algorithms are:
• XPRESS4K (fastest and default value)
• XPRESS8K
• XPRESS16K
• LZX (most compact)
/CompactOs Sets or queries the system's compression state. Supported options are:
• query - Queries the system's Compact state.
• always - Compresses all operating system binaries and sets the system state to Compact, which remains unless administrator changes it.
• never - Uncompresses all operating system binaries and sets the system state to non-Compact, which remains unless administrator changes it.
/windir Used with the /CompactOs:query parameter, when querying the offline operating system. Specifies the directory where Windows is installed.
`<filename>` Specifies a pattern, file, or directory. You can use multiple file names, and the * and ? wildcard characters.
/? Displays help at the command prompt.

#### Remarks

• This command is the command-line version of the NTFS file system compression feature. The compression state of a directory indicates whether files are automatically compressed when they are added to the directory. Setting the compression state of a directory does not necessarily change the compression state of files that are already in the directory.

• You can't use this command to read, write, or mount volumes compressed using DriveSpace or DoubleSpace. You also can't use this command to compress file allocation table (FAT) or FAT32 partitions.

## Examples

To set the compression state of the current directory, its subdirectories, and existing files, type:

``````compact /c /s
``````

To set the compression state of files and subdirectories within the current directory, without altering the compression state of the current directory itself, type:

``````compact /c /s *.*
``````

To compress a volume, from the root directory of the volume, type:

``````compact /c /i /s:\
``````

Note

This example sets the compression state of all directories (including the root directory on the volume) and compresses every file on the volume. The /i parameter prevents error messages from interrupting the compression process.

To compress all files with the .bmp file name extension in the \tmp directory and all subdirectories of \tmp, without modifying the compressed attribute of the directories, type:

``````compact /c /s:\tmp *.bmp
``````

To force complete compression of the file zebra.bmp, which was partially compressed during a system crash, type:

``````compact /c /f zebra.bmp
``````

To remove the compressed attribute from the directory c:\tmp, without changing the compression state of any files in that directory, type:

``````compact /u c:\tmp
``````