General Compress or Uncompress Files and Folders in Windows 11

  • Thread starter Thread starter Brink
  • Start date Published: Start date Updated Updated:

Compress_banner.webp

This tutorial will show you how to compress or uncompress a file or folder with NTFS Compression in Windows 10 and Windows 11.

The NTFS file system volumes support file compression on an individual file basis. The file compression algorithm used by the NTFS file system is Lempel-Ziv compression. This is a lossless compression algorithm, which means that no data is lost when compressing and decompressing the file, as opposed to lossy compression algorithms such as JPEG, where some data is lost each time data compression and decompression occur.

Data compression reduces the size of a file by minimizing redundant data. In a text file, redundant data can be frequently occurring characters, such as the space character, or common vowels, such as the letters e and a; it can also be frequently occurring character strings. Data compression creates a compressed version of a file by minimizing this redundant data.

While NTFS file system compression can save disk space, compressing data can adversely affect performance. NTFS compression has the following performance characteristics. When you copy or move a compressed NTFS file to a different folder, NTFS decompresses the file, copies or moves the file to the new location, and then recompresses the file. This behavior occurs even when the file is copied or moved between folders on the same computer. Compressed files are also expanded before copying over the network, so NTFS compression does not save network bandwidth.

The /EXE parameter for the compact command 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, but uses a lot of CPU resources)
Files or folders saved into an existing compressed folder will automatically be compressed.

NTFS compressed files and folders will have double blue arrows overlay on their icon at the top right corner to indicate that they are compressed.

References:


A file or folder compressed by NTFS Compression is not the same as a Zipped file or folder.

You will only be able to compress or encrypt (EFS) a file or folder. Not both. As a workaround, you could use BitLocker on the drive to encrypt everything on the drive, and then be able to compress what you want.



Contents



EXAMPLE: Files and Folders compressed using NTFS Compression

NTFS_Compression.png





Option One

Compress or Uncompress File(s) in Properties


1 Right click or press and hold on one or more selected file(s), and click/tap on Properties. (see screenshot below)

Compress_file-1.png

2 In the General tab, click/tap on the Advanced button. (see screenshot below)

Compress_file-2.png

3 Check (compress) or uncheck (uncompress - default) Compress contents to save disk space for what you want, and click/tap on OK. (see screenshot below)

Compress_file-3.png

4 Click/tap on OK. (see screenshot below)

Compress_file-4.png




Option Two

Compress or Uncompress Folder(s) in Properties


1 Right click or press and hold on one or more selected folder(s), and click/tap on Properties. (see screenshot below)

Compress_folder-1.png

2 In the General tab, click/tap on the Advanced button. (see screenshot below)

Compress_folder-2.png

3 Check (compress) or uncheck (uncompress - default) Compress contents to save disk space for what you want, and click/tap on OK. (see screenshot below)

Compress_folder-3.png

4 Click/tap on OK. (see screenshot below)

Compress_folder-4.png

5 Select (dot) Apply changes to this folder only or Apply changes to this folder, subfolders and files for what you want, and click/tap on OK. (see screenshot below)

Compress_folder-5.png




Option Three

Compress File using Command


1 Open Windows Terminal, and select either Windows PowerShell or Command Prompt.

2 Type the command below into Windows Terminal, and press Enter. (see screenshot below)

compact /c "<full path of file>" /i /Q

Substitute <full path of file> in the command above with the actual full path of the file you want to compress.

For example: compact /c "C:\Users\Brink\Desktop\File.txt" /i /Q


compress_file_command.png





Option Four

Uncompress File using Command


1 Open Windows Terminal, and select either Windows PowerShell or Command Prompt.

2 Type the command below into Windows Terminal, and press Enter. (see screenshot below)

compact /u "<full path of file>" /i /Q

Substitute <full path of file> in the command above with the actual full path of the compressed file you want to uncompress.

For example: compact /u "C:\Users\Brink\Desktop\File.txt" /i /Q


uncompress_file_command.png





Option Five

Compress Folder using Command


1 Open Windows Terminal, and select either Windows PowerShell or Command Prompt.

2 Type the command below you want to use into Windows Terminal, and press Enter. (see screenshot below)

(Apply changes to this folder only)​
compact /c "<full path of folder>" /i /Q

OR​

(Apply changes to this folder, subfolders and files)​
compact /c /s:"<full path of folder>" /i /Q

Substitute <full path of folder> in the command above with the actual full path of the folder you want to compress.

For example: compact /c /s:"C:\Users\Brink\Desktop\Folder" /i /Q


compress_folder_and_contents_command.png





Option Six

Uncompress Folder using Command


1 Open Windows Terminal, and select either Windows PowerShell or Command Prompt.

2 Type the command below you want to use into Windows Terminal, and press Enter. (see screenshot below)

(Apply changes to this folder only)​
compact /u "<full path of folder>" /i /Q

OR​

(Apply changes to this folder, subfolders and files)​
compact /u /s:"<full path of folder>" /i /Q

Substitute <full path of folder> in the command above with the actual full path of the compressed folder you want to uncompress.

For example: compact /u /s:"C:\Users\Brink\Desktop\Folder" /i /Q


uncompress_folder_and_contents_command.png



That's it,
Shawn Brink


 
Last edited:
For the record, you can select a higher compression algorithm, but it will cost you more CPU.
Code:
XPRESS4K (fastest and default value)
XPRESS8K
XPRESS16K
LZX (most compact)

compact /c /i /q /f /exe:lzx /s:C:\
For comparison:
Uncompressed disk: 20GB
Standard compression: 18GB
Maximum compression: 14GB

capture_01212023_153943.jpg
 

My Computer

System One

  • OS
    Windows 11 Home
    Computer type
    PC/Desktop
    CPU
    AMD Ryzen 5 8600G (07/24)
    Motherboard
    ASROCK B650M-HDV/M.2 3.20 (07/24)
    Memory
    2x32GB Kingston FURY DDR5 5600 MHz CL36 @5200 CL40 (07/24)
    Graphics Card(s)
    ASROCK Radeon RX 6600 Challenger D 8G @48FPS (08/24)
    Sound Card
    Creative Sound BlasterX AE-5 Plus (05/24)
    Monitor(s) Displays
    24" Philips 24M1N3200ZS/00 (05/24)
    Screen Resolution
    1920×1080@165Hz via DP1.4
    Hard Drives
    Kingston KC3000 NVMe 2TB (05/24)
    ADATA XPG GAMMIX S11 Pro 512GB (07/19)
    PSU
    Seasonic Core GM 550 Gold (04/24)
    Case
    Fractal Design Define 7 Mini with 3x Noctua NF-P14s/12@555rpm (04/24)
    Cooling
    Noctua NH-U12S with Noctua NF-P12 (04/24)
    Keyboard
    HP Pavilion Wired Keyboard 300 (07/24) + Rabalux 76017 Parker (01/24)
    Mouse
    Logitech M330 Silent Plus (04/23)
    Internet Speed
    500/100 Mbps via RouterOS (05/21) & TCP Optimizer
    Browser
    Edge & Brave for YouTube & LibreWolf for FB
    Antivirus
    NextDNS blocking 99% TLDs
    Other Info
    Backup: Hasleo Backup Suite (PreOS)
    Headphones: Sennheiser RS170 (09/10)
    Phone: Samsung Galaxy Xcover 7 (02/24)
    Chair: Huzaro Force 4.4 Grey Mesh (05/24)
    Notifier: Xiaomi Mi Band 9 Milanese (10/24)
    2nd Monitor: AOC G2460VQ6 @75Hz (02/19)
Thanks for this tutorial. The command "compact" worked-around two failures that were occurring with Explorer's compression operation.
With one folder, Explorer did not even respond. Showed nothing, and did nothing.
With other folder, operation quit on an error; solved by command's /i switch.

Question regarding manual uploading of compressed files into OneDrive account IN WEB (no OneDrive anything is in my computer) :
Before I compressed, I saw that folders in website apparently had been compressed by OneDrive server (smaller than in Explorer). I deleted them, and will re-upload. This time the folders already are compressed in computer. Question is whether DEcompression is performed in the uploading process. (I know that they will end up compressed in storage).
 

My Computer

System One

  • OS
    Win11 Pro 23H2
Thanks for this tutorial. The command "compact" worked-around two failures that were occurring with Explorer's compression operation.
With one folder, Explorer did not even respond. Showed nothing, and did nothing.
With other folder, operation quit on an error; solved by command's /i switch.

Question regarding manual uploading of compressed files into OneDrive account IN WEB (no OneDrive anything is in my computer) :
Before I compressed, I saw that folders in website apparently had been compressed by OneDrive server (smaller than in Explorer). I deleted them, and will re-upload. This time the folders already are compressed in computer. Question is whether DEcompression is performed in the uploading process. (I know that they will end up compressed in storage).

Hello, :alien:

It depends.

If the compressed files are moved to the OneDrive location on your PC, they will stay compressed.

They will not stay compressed if moved to the OneDrive online cloud location.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    CyberPower CP1500PFCLCD
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Surface Laptop 7 Copilot+ PC
    CPU
    Snapdragon X Elite (12 core) 3.42 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Monitor(s) Displays
    15" HDR
    Screen Resolution
    2496 x 1664
    Hard Drives
    1 TB SSD
    Internet Speed
    Wi-Fi 7 and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender

Latest Support Threads

Back
Top Bottom