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.
compact [/C | /U] [/S[:dir]] [/A] [/I] [/F] [/Q] [/EXE[:algorithm]] [/CompactOs[:option] [/windir:dir]] [filename [...]]
|/c||Compresses the specified directory or file. The app marks directories so that the app compresses any files added afterward, unless the /EXE parameter is specified.|
|/u||Uncompresses the specified directory or file. Directories are marked so the app does not compress any files added afterwards. If you specify the /EXE parameter is specified, the app will only uncompressed files compressed as executables ; if you don’t specify the /EXE parameter, the app will onlyuncompress NTFS compressed files.|
||Performs the chosen operation on files in the specified directory and all subdirectories. By default, the current directory equals the
|/a||Displays hidden or system files. By default, the app does not include these files.|
|/i||Continues performing the specified operation, ignoring errors. By default, this command causes the app to stops when an error is encountered.|
|/f||Forces compression or uncompression of the specified directory or file. The app skips already-compressed files by default. The app uses the /f parameter in the case of a file that was partly compressed when the operation was interrupted by a system crash. To force the app to compress the file 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:
|/CompactOs||Sets or queries the system’s compression state. Supported options are:
|/windir||Used with the /CompactOs:query parameter, when querying the offline operating system. Specifies the directory where Windows is installed.|
||Specifies a pattern, file, or directory. You can use multiple file names, and the * and ? wildcard characters.|
|/?||Displays help at the command prompt.|
- This command represents 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.
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:\
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