Compact: Compresses and Decompresses NTFS Files and Folders

Compact is the command-line version of the compression functionality in My Computer. Compact displays and alters the compression of folders and files on NTFS volumes. It also displays the compression state of folders. For more information about this program, at the command prompt type:

compact /?

Table 3.15 describes the options available with Compact. The syntax of the command is:

compact [ /c ] [ /u ] [ /s [ **:**folder ]] [ /a ] [ /i ] [ /f ] [ /q ] [ filename [...]]

Table   3.15 Compact Options




Displays the compression state of the current folder.


Compresses the specified folder or file.


Decompresses the specified folder or file.

/s [ :folder ]

Specifies that the requested action (compress or decompress) be applied to all subfolders of the specified folder, or to the current folder if none is specified.


Ignores errors.


Forces a specified folder or file to compress or decompress.


Displays files with the hidden or system attribute.


Reports only the most essential information.


Specifies a pattern, file, or folder. You can use multiple file names and wildcard characters.

The following are reasons to use this utility rather than My Computer:

  • You can use Compact in a batch script. Using the /i option enables you to skip files that cannot be opened when you are running in batch mode, such as files already in use by another program.

  • If the system failed during compression or decompression, the file or folder is marked as Compressed or Uncompressed, even if the operation did not complete. You can force the operation to complete by using Compact with the /f option (with either the /c or /u option).



Compact automatically compresses or decompresses all of the files and subfolders when you change the compression state of a folder. It does not ask whether you want to change the compression state of the files or subfolders in it.

Volume Compression Requirements

When you attempt to compress a volume that is very low on free space, you might receive an error indicating that there was insufficient space to perform the action.

These errors indicate that the system needs additional free space to perform a compression. The system is not designed to manipulate the data in place on the disk. Additional space is needed to buffer the user data and to hold additional file system metadata. The amount of additional free space required depends on the cluster size, file size, and available space.