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

Raymond Chen

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.

Bonus reading: Functions for manipulating documents which follow the Open Package Conventions are available in both managed and unmanaged versions. Check out the Packaging Team Blog for more information, including a comparison of the managed and unmanaged versions.

0 comments

Discussion is closed.

Feedback usabilla icon