How do I transparently compress a directory?

Solution 1:

The compression is supported by HFS+ file-system out of box, however macOS by default doesn't compress any files.


afsctool

There is a afsctool command-line utility which can transparently compress the files, for example:

afsctool -c some_dir

Install via: brew install afsctool.


ditto

When copying files, use ditto, e.g.

ditto --hfsCompression src dst

When copying files or extracting content from an archive, all the content will be compressed if appropriate.

To check whether a file is compressed using HFS+ compression or not, you can use hfsdebug. See: Compress files with HFS+ compression.


Related: Transparent file compression apps for macOS.