A utility for intelligent file compression on Windows 10/11 systems using the built-in NTFS compression algorithms and Windows' built-in "compact.exe" utility. Compressing files at the filesystem level is quite different from your average .zip or .7z compression (which is strictly for archival purposes) and it's seamless - you won't see a difference, but the apps will shrink in size without deleting anything.
Unlike CompactGUI and Compactor (tools based on compact.exe and primarily designed for compressing Steam games), this program automatically scans through the files, evaluating their compressibility with a complex but fast algorithm, and picking the optimal compression algorithm based on file size - this lets you squeeze the most out of the compression algorithms and get even smaller file sizes, all while avoiding unnecessary compression, maximising overall system performance in comparison with the aforementioned tools, and preventing excessive SSD wear, keeping things DRY.
Compressing large directories to gain extra storage space will be so free and without downsides that it'll be the closest thing to having "free real estate".
- Automated compression using Windows NTFS compression
- Simple and intuitive user interface
- Smart algorithm selection based on file size
- Entropy analysis to evaluate compression potential and choose to compress only the files that will make sense to compress
- Configurable minimum savings threshold (
--min-savings) with interactive controls - Multiple operation modes for different use cases
- Skips poorly-compressed file formats (zip, media files, etc.)
- Skips already-compressed files
- Skips using LZX compression if the computer is identified as too slow to handle it without performance losses (taking care of users)
- Detailed compression and file throughput stats
- It's only for storage devices with an NTFS file system, like your system drive and external flash drives and SSDs if they're formatted to use NTFS. If it's FAT32, exFAT or ReFS - it won't work for you.
- It's best to assume that it likely won't work on network drives even if they are formatted to NTFS (haven't tested it).
- Spinning hard drives might get fragmented, negatively impacting read performance.
- Windows 10/11
- Optional: Administrator privileges are optional for normal compression runs. They are required for compressing Windows system binaries using CompactOS (
compact.exe /compactos:always) in 1-click mode
- Download the latest release
- Run the executable file
- Open PowerShell
- Clone and navigate to the repository:
git clone https://github.com/misha1350/trash-compactor.git cd trash-compactor
- Run the program:
python main.py
Note: For Option 2, ensure Git and Python 3.11 or 3.12 are installed on your system.
Optional: you can compile the app yourself as I did, using PyInstaller:
powershell python -m PyInstaller --onefile --add-data "locales;locales" --add-data "src/gui/ui;src/gui/ui" --name trash-compactor-next main.py
or, since we're interested in squeezing programs into small packages, you can install a build of UPX to build an app with compressed binaries:
powershell python -m PyInstaller --onefile --add-data "locales;locales" --add-data "src/gui/ui;src/gui/ui" --name trash-compactor-next --upx-dir 'c:\path\to\upx-win64' main.py
- Run the program.
- Use Administrator only if you want 1-click mode to launch Windows CompactOS.
- Choose the mode - either the 1-click run mode to get most things done fast or choose the directory.
- The program will automatically:
- Scan all files recursively
- Skip poorly compressible files
- Apply optimal compression algorithms
- Display compression statistics
Launching without arguments opens a GUI window that lets you browse to the target directory, toggle flags, and adjust the minimum savings threshold before starting.
- Choose the directories you wish to compress or click on "Quick Compression".
- Tweak settings such as Minimum Savings % to change the skip threshold, disable LZX compression so as to only dynamically use XPRESS4K/8K/16K algorithms, or use a single worker if you have a spinning hard drive.
- Press "Analyse" to see what can be compressed.
- Yellow projected values mean that while some files may be compressed, you'll save less than the Minimum Savings % on average.
- Green projected values indicate that you'll save 1.01x-1.99x of the Minimum Savings % on average.
- Blue projected values indicate that you'll save more than double of the Minimum Savings % on average. Go for it!
- If it looks good to you, press "Compress" to compress the files in the directory.
Trash-Compactor offers three distinct operation modes to handle different scenarios:
Pressing or passing 1 upon starting will run this mode. Most users can just compress their directories once and forget about it. Designed to be extremely simple to use for a casual user, a system administrator, refurbisher, or the so-called family tech support.
This mode will automatically compress the following directories:
Program FilesProgram Files (x86)(including your Steam folder)AppDataDownloadsWindowsvia CompactOS only when running as Administrator (you will be prompted first)
Expect at least 15GB to be saved on stock Windows installations.
If launched without Administrator privileges, 1-click mode still performs regular compression on accessible files and directories, while CompactOS is skipped automatically.
If launched with Administrator privileges, 1-click mode asks whether to start CompactOS before scanning begins. If you accept, CompactOS starts immediately in a separate window while the directory scan/analysis runs.
For first-time compression of directories with optimal performance. Be aware that temporarily disabling the anti-virus or whitelisting this program is going to greatly improve the compression speed.
.\trash-compactor.exe C:\path\to\compressTo check how well a directory will compress without writing anything to the drive. SSDs have a finite amount of data that can be written, so some users might check if it's worth bothering to compress their directory.
.\trash-compactor.exe -d C:\path\to\compressLZX compression is turned on for large files by default. LZX compression is resource-intensive and files will take some time to compress, though it does result in better compression of both compressible binaries and the files that XPRESS16K doesn't compress as well. But if you have a computer that was build or made before AD 2021, or if battery life is absolutely critical for you (a big problem on Intel Coffee Lake laptops), you may want to disable it.
HDDs read data sequentially and they can't handle the extreme I/O that the program will hammer the drive with, so to avoid excessive fragmentation, one should use this flag to reduce fragmentation somewhat.
-v, or--verbose: Show exclusion decisions with entropy sampling (supports 4 levels of verbosity, up to-vvvvfor debug logs)-m, or--min-savings <percent>: Set the minimum estimated savings (0-90, default 18%). Directories predicted to save less space are skipped automatically
Trash-compactor stores high-entropy directory decisions in an on-disk cache to avoid re-sampling the same low-value directories on future runs.
- Windows path:
%APPDATA%\TrashCompactor\incompressible.db - Fallback path, if
%APPDATA%is not set:~/.cache/TrashCompactor/incompressible.db - Append-only text file, one hash per line
xxhash64hash function over absolute directory path strings
The cache is loaded into memory at startup. New high-entropy entries are staged during analysis and written to disk only after a compression run completes.
To contribute to this project:
- Create a new branch for your feature.
- Submit a pull request.
Put a "star" if you find this project helpful or cool. I don't know what they do, apart from giving some small bragging rights, but maybe it might get introduced to more people, which will be great, as the collective storage savings will contribute to less e-waste - especially if an SSD is soldered onto the laptop's motherboard and is not replaceable, turning the laptop into a paperweight if it fails prematurely - which it surely will.
- Fix bugs:
- The terminal will close immediately when the GUI is spawned, if you run the program from the terminal instead of Windows Explorer
- Research advanced compression methods:
- Evaluate alternative NTFS compression APIs, like UPX
- Consider filesystem-agnostic approaches (moving compressed files in/out of the source drive unpacks them)
- Benchmark different compression strategies
- Research possibilities for custom compression algorithms
- Investigate integration with other Windows compression features
- Quality of Life features:
- Add resume capability for interrupted operations
- Security and Reliability:
- Improve handling and messaging for network/NAS paths
- Add verification of filesystem compatibility
- Backburner / deferred:
- DirectStorage detection research (defer until a dedicated test matrix is available)