The Hidden Cost of Large Files
Modern storage drives are incredibly fast, but their capacity often feels surprisingly limited. Between massive 4K video projects, complex virtual machine images, and massive game installs, a 1TB SSD can fill up in a matter of months.
While you can use third-party archiving tools like 7-Zip or WinRAR to compress old files into .zip or .rar archives, that process is fundamentally inconvenient. If you want to use the file again, you have to extract it, taking up even more space and wasting time.
Windows 11 features a built-in, virtually invisible feature of the NTFS file system called transparent compression. When a file is compressed using this method, it shrinks on the hard drive to save space, but to you and all your applications, it looks and acts like a normal, uncompressed file. Windows handles the decompression on-the-fly in the RAM when you open it.
While you can right-click a folder, go to Properties, and check “Compress contents to save disk space,” doing this for massive, nested directory trees via the GUI can be incredibly slow and prone to crashing. To compress large amounts of data reliably, you should use the compact command.
Step 1: Checking the Compression Status of a Folder
Open the Command Prompt or PowerShell. You do not strictly need Administrator privileges unless you are trying to compress system files (which is generally not recommended).
To see the current compression status of the files in your current directory, simply type:
compact
The terminal will output a list of files in that folder. For each file, it will show the original size, the compressed size, the compression ratio, and a “C” or “U” indicating if the file is Compressed or Uncompressed.
Step 2: Compressing a Single File or Folder
To compress a specific file, use the /C (compress) switch followed by the filename.
compact /C "C:\Users\Name\Documents\massive_database.csv"
If you want to compress an entire folder, it is crucial to understand that simply targeting the folder only changes the attribute of the folder itself, meaning future files placed in it will be compressed, but the existing files won’t be touched.
To compress the folder and all the files currently inside it, use the wildcard (*):
compact /C "C:\Users\Name\Archives\*"
Step 3: Compressing Subdirectories (The /S Switch)
This is where the GUI fails and the terminal shines. If you have a massive “Projects” folder containing hundreds of subfolders, thousands of files, and gigabytes of data, you need the command to traverse the entire directory tree.
To recursively compress a folder, all its subfolders, and all the files within them, use the /S (subdirectory) switch.
compact /C /S:"C:\Users\Name\Old_Projects"
If you encounter files that are currently open in other programs, compact will normally stop and throw an error. If you are running a massive batch job overnight and want it to ignore errors and keep going, add the /I (ignore) switch:
compact /C /S:"C:\Users\Name\Old_Projects" /I
Step 4: Decompressing Data
If you notice that a specific folder (like a folder containing high-performance database files) is running slightly slower because the CPU has to constantly decompress the data on-the-fly, you can reverse the process.
To uncompress data, swap the /C switch for the /U (uncompress) switch.
To uncompress a folder and all of its subdirectories recursively:
compact /U /S:"C:\Users\Name\Old_Projects" /I
Important Considerations
Transparent NTFS compression is highly effective for text files, logs, CSVs, and uncompressed bitmaps. However, it is a waste of CPU cycles to run it against file formats that are already highly compressed by design, such as MP4 videos, JPEG images, or ZIP archives. The compact command will try to shrink them, but the resulting file size will remain virtually identical.