NTFS enhanced compact button (with shutdown)

Running out of disk space on your Steam SSD drive? You've already enabled the NTFS compression, but still need just a little bit more space? Well, read on!

I'm sharing the button which recursively compacts the contents of the current folder and its subfolders using (non-default) enhanced variant (LZX) of the NTFS compression, which is optimized for executable & binary files. The button can also optionally shutdown the computer after the compression is done.

We're using official Microsoft functionality already present in the Windows OS. No extra downloads or tools needed.

Real world example of my own disk space savings for Steam library:
No compression applied: 291 GB
Default NTFS compression (size on disk): 276 GB
LZX NTFS compression (size on disk): 262 GB

Here is the button code:

@confirm This will recursively compress everything in the current SOURCE path.
@set shdwn={dlgchoose|Shut down the computer on complete|No=rem+Yes=shutdown /s}
@echo off
title Compact
compact * /c /s /i /exe:lzx
{$shdwn}

Or download the pre-made button:
LZX compact here.dcf (605 Bytes)

What it does
It invokes the Windows' built-in command compact with additional parameter to use the LZX compression which yields better compression ratio. Since this can be a lengthy process, the button also asks whether to shutdown the computer after it's done. Upon the completion, if "Yes" was selected, the Windows will display a full screen warning that the computer will shutdown in less than a minute (tip: you can abort this shutdown with a shutdown /a command in the command prompt).

Caveats

  • Running this will clear any "compressed" attributes of the files/folders.
  • Since the "compressed" attributes are cleared, any new files won't automatically be compressed (like they would be with the default NTFS compression). In case of e.g., Steam game updates, you'll have to re-run the button command (it should skip over any already-compressed files automatically though).
  • Setting the "compressed" attribute manually with Opus won't make it auto-compress new files I think (or at least not with LZX).
  • In case the files are already compressed with the default NTFS compression, you can add the /f commandline switch to force re-compression of all files (open the command prompt in the target folder and run compact * /c /s /i /f /exe:lzx), otherwise they will be skipped.
  • Even though the LZX variant requires more CPU than the default NTFS compression (which is optimized for speed and not compression ratio), there should be no adverse impact on the loading times (may even improve it depending on the types of the data files and the drive).
  • Tip: check the "size on disk" in the folder properties for the size difference to confirm that the LZX compression indeed took place.
  • Tip 2: To abort the ongoing compression process, use CTRL+C and wait for the "terminate batch job?" prompt.
2 Likes