Compress/Decompress

compact /c <file_or_folder>

Compresses a file or folder.

compact /u <file_or_folder>

Decompresses a file or folder.

compact /q <file_or_folder>

Queries the compression status of a file or folder.

expand <compressed_file> <destination_folder>

Decompresses a file using Microsoft's Expand utility.

Compress a folder to a ZIP file:

Compress-Archive -Path C:\path\to\sourceFolder -DestinationPath C:\path\to\output.zip

Decompress a ZIP file to a folder:

Expand-Archive -Path C:\path\to\input.zip -DestinationPath C:\path\to\destinationFolder

Compress multiple files into a ZIP file:

Compress-Archive -Path "C:\path\to\file1.txt", "C:\path\to\file2.txt" -DestinationPath C:\path\to\output.zip

Compress a folder using Windows built-in command (CMD):

powershell -command "Compress-Archive -Path C:\path\to\sourceFolder -DestinationPath C:\path\to\output.zip"

Decompress a ZIP file using Windows built-in command (CMD):

powershell -command "Expand-Archive -Path C:\path\to\input.zip -DestinationPath C:\path\to\destinationFolder"

Compress a folder to a ZIP file with maximum compression:

Compress-Archive -Path C:\path\to\sourceFolder -DestinationPath C:\path\to\output.zip -CompressionLevel Optimal

Decompress a specific file from a ZIP file:

Expand-Archive -Path C:\path\to\input.zip -DestinationPath C:\path\to\destinationFolder -Include "specificFile.txt"

Compress files excluding certain files:

Compress-Archive -Path C:\path\to\sourceFolder\* -DestinationPath C:\path\to\output.zip -Exclude "*.log"

makecab: Creates cabinet (.cab) files for software distribution (older format).

extrac32: Extracts files from .cab files.

Create a CAB file from a single file:

makecab C:\path\to\sourceFile.txt C:\path\to\outputFile.cab

Create a CAB file from multiple files using a directive file:

makecab /f C:\path\to\directive.ddf

Extract files from a CAB file using extrac32:

extrac32 C:\path\to\sourceFile.cab C:\path\to\destinationFolder

Extract a specific file from a CAB file using extrac32:

extrac32 /L C:\path\to\destinationFolder C:\path\to\sourceFile.cab specificFile.txt

Display contents of a CAB file without extracting (using extrac32):

extrac32 /D C:\path\to\sourceFile.cab

Last updated

Was this helpful?