compressionbrotli

compress list of files and directories with brotli


I'd like to use brotli to compress a list of files and directories. I'm able to do this with zip running

zip -r  archive.zip *

and I'm looking for a similar command with brotli. I've tried

tar -cf archive.gz * && \
brotli -n -q 11 -o archive.zip archive.gz

but after decompression the zip doesn't have the same structure than with zip.


Solution

  • Your second command is actually right. Brotli, like Gzip/Bzip2/etc can only compress a single file.

    What you must do is first package all of your files in a tarball:

    tar -cvf output.tar /path/to/dir
    

    And then compress the resulting tarball with Brotli:

    brotli -j -Z output.tar
    

    Which should leave you with a output.tar.br file (similar to *.tar.gz gzipped tarballs).