Skip to content

What is COMPACT Windows command?

The Windows compact command is a powerful tool that allows users to compress files and directories on their system, saving disk space and reducing storage usage. By using this command, you can reclaim valuable storage space on your hard drive by compressing files and directories with NTFS compression. This can be especially useful for freeing up space on your system drive or when transferring files over the network. The compact command offers various options to customize the compression process, such as specifying whether to compress subdirectories, setting the compression type, and viewing detailed compression statistics. Additionally, you can use the compact command to decompress previously compressed files and directories if needed. Overall, mastering the Windows compact command can help you better manage your storage space and optimize the performance of your system.

COMPACT Syntax:

Terminal window
compact [option] [parameter]

COMPACT Options:

OptionDescription
/CCompresses the specified file
/UUncompresses the specified file
/SApplies the action to the current directory and all subdirectories
/ADisplay files compressed or uncompressed
/IIgnore errors and continue the operation even if errors are detected
/QReports only the most essential information related to the operation
/IIgnore errors and continue the operation even if errors are detected
/FForces the compression or uncompression operation even if errors are detected

Parameters:

ParameterDescription
FileNameSpecifies the file to compress or uncompress
/SApplies the action to the current directory and all subdirectories
SubDirNameSpecifies the subdirectory to compress or uncompress
/IIgnore errors and continue the operation even if errors are detected

COMPACT Command Usage Examples:

Compress a File

Terminal window
compact /c file.txt

Compresses the specified file “file.txt” to reduce the file size.

Decompress a File

Terminal window
compact /u file.txt

Decompresses the specified compressed file “file.txt” to restore the original file size.

List Compression State of Files

Terminal window
compact /s:C:\Folder\ /a

Lists the compression state of files in the specified folder “C:\Folder” including their sizes before and after compression.

Compact a Directory (including subdirectories)

Terminal window
compact /c /s:C:\Folder\

Compresses all files in the specified directory “C:\Folder” and its subdirectories to save disk space.

Display Help Information

Terminal window
compact /?

Displays help information about the usage and parameters of the compact command.

How do I use compact in CMD?

To use the compact command in CMD, execute the following command:

Terminal window
compact /c /s:C:\ExampleFolder

Can I use compact to compress specific files in CMD?

Yes, you can use the compact command to compress specific files in CMD.

Terminal window
compact /C C:\ExampleFolder\file.txt

How can I decompress files with compact in CMD?

To decompress files with compact in CMD, you can use the /U parameter.

Terminal window
compact /U C:\ExampleFolder\compressed_file.txt

Is it possible to list the compression state of files with compact?

Yes, you can list the compression state of files using the compact command with the /s parameter.

Terminal window
compact /s:C:\ExampleFolder

How can I show detailed information about a compressed file with compact in CMD?

You can show detailed information about a compressed file in CMD using the /I parameter.

Terminal window
compact /I C:\ExampleFolder\compressed_file.txt

Can I set a compression state for a folder and its subfolders with compact?

Yes, you can set a compression state for a folder and its subfolders using the /S parameter.

Terminal window
compact /C /S C:\ExampleFolder

How can I exclude specific files or file types from compression with compact in CMD?

To exclude specific files or file types from compression using compact in CMD, use the /EXE parameter.

Terminal window
compact /C /I /EXE:.txt /S C:\ExampleFolder

Applications of the COMPACT Command

  • Compress files or directories to save disk space
  • View compression status of files
  • Decompress files or directories to their original size
  • Set compression attributes for files or directories