My Blog

A classic static blog

commands-7z maximum compression files and dir

To compress the contents of the music/ directory into a 7z file with maximum compression in Termux, follow these steps:

  1. Install p7zip (if not already installed):
pkg install p7zip
  1. Compress the music/ directory with maximum compression:
7z a -mx=9 -m0=LZMA2:d=64m -mmt=on music.7z music/

Explanation of Options:

· a: Add files to the archive. · -mx=9: Maximum compression level. · -m0=LZMA2:d=64m: Use the LZMA2 compression method with a 64MB dictionary (improves compression ratio). · -mmt=on: Enable multithreading for faster compression (if supported by your device).

Alternative: Compress Files Without Including the Parent Directory

If you want the archive to contain the files inside music/ (not the directory itself):

cd music && 7z a -mx=9 -m0=LZMA2:d=64m -mmt=on ../music.7z ./*

Notes:

· Replace music/ with the correct path to your directory if you’re not in the parent directory. · Compression time and memory usage will increase with larger dictionary sizes (e.g., d=64m). Adjust based on your device’s capabilities.

The resulting music.7z file will be created in your current working directory.