Windows – Force all files in a NTFS compressed folder to automatically compress [Windows]

compressionfilesystemswindowszip

Is it possible to keep all the files within a NTFS-compressed folder compressed?

For example, if I have a compressed a folder using NTFS compression, it will compress all the files inside the folder as well.
However, when I copy a file that is not compressed into the folder, the file won't automatically compress, it will stay uncompressed. Is it possible to force compress the files when moving them in (and potentially uncompress when moving out)?

I would like to use this on backup folders etc. Also, I would like to keep using the original NTFS compression if possible, it's very convenient

Best Answer

When you copy uncompressed files into a NTFS compressed folder the compression level isn't changed, and you cannot set them to compress them automatically (only newly created files are created as compressed). Instead you have to use compact.exe to compress all the files in the folder after you have moved files in there. You can do this using a batch file - change directory to the compressed directory and run the command:

compact /c (use /s to include subdirectories)

or, to save changing directory:

compact /c "c:\compressedfolder\*.*"