Thursday, June 23, 2011

How do I compress files (via NTFS compression) from the command line?

A customer wanted to know whether there was a way to compress files and directories (in the sense of NTFS compression) from a script or from the command line. They knew about the Properties dialog, but they wanted something scriptable.
The command-line tool for this is COMPACT.EXE. Type compact /? for usage information.
The customer liaison was grateful for this information.
Thanks for the prompt response, and yes, this will meet our customer's need to compress specific files such as *.docx under a particular directory and all its subdirectories.
Um, *.docx files are already compressed. Compressing them again gains you nothing.