45

How can I convert this settings into command?

enter image description here

Here are the results:

// Manual Compression (see the image above)
Compressed Size: 12,647,451 bytes

// Ultra
7z a -t7z Files.7z -mx9 -aoa
Compressed Size: 12,676,886 bytes

// LZMA2
7z a -t7z Files.7z -m9=LZMA2 -aoa
Compressed Size: 14,237,515 bytes  

I am looking here:
http://sevenzip.sourceforge.jp/chm/cmdline/switches/method.htm

I am about to put this in a batch file.

fiberOptics
  • 6,955
  • 25
  • 70
  • 105
  • may be, if run in development or debug mode, you could gather these options as command line arguments? – Aquarius Power Nov 14 '14 at 15:45
  • -aoa is an extraction option. It means don't overwrite files that already exist on disk. It is ignored when compressing files to an archive. – Able Mac Jul 03 '19 at 11:14

5 Answers5

69

Your command line should be at least:

7z a -t7z Files.7z -m0=lzma2 -mx=9 -aoa

Note that you'll get better compression when using 1 or 2 threads, not 8. So, even closer to your GUI settings (ms : solid, d : dictionary size, mhe : encrypt header (file names), p : password)

7z a -t7z -m0=lzma2 -mx=9 -aoa -mfb=64 -md=32m -ms=on -d=1024m -mhe -pSECRET
tricasse
  • 1,299
  • 13
  • 18
  • 10
    I'm not sure as of which 7z version it barfs on `-d=1024m`, but this works for version 16.04 on Windows: `7z.exe a -t7z -m0=lzma2:d1024m -mx=9 -aoa -mfb=64 -md=32m -ms=on`. I also append ` -sdel` to the options for moving files to an archive. – Jeroen Wiert Pluimers Jan 03 '17 at 11:50
  • 1
    Using 1, 2 or 3 threads uses the same amount of memory for compression which makes me think that they all share the same dictionary. Based on my tests, there's no drop in compression efficiency for up to 3 threads. – milivojeviCH Jan 09 '17 at 10:50
  • 2
    -aoa is an extraction option. It means don't overwrite files that already exist on disk. It is ignored when compressing files to an archive. – Able Mac Jul 03 '19 at 11:15
  • What is the significance of `-t7z`? – Nilesh Jan 04 '20 at 16:46
  • @Nilesh: `-t7z` = archive type 7z – tricasse Jan 08 '20 at 09:22
10

It's hard to get the same result, but this is the best I can get so far:

7z a -t7z Files.7z -m0=BCJ2 -m1=LZMA2:d=1024m -aoa
fiberOptics
  • 6,955
  • 25
  • 70
  • 105
8

For those who are on unix system, this is how I achieved this.

7z a -t7z -m0=lzma2 -mx=9 -mfb=64 -md=1024m -ms=on destination.7z Source

My source: http://manpages.ubuntu.com/manpages/artful/man1/7z.1.html

RAWDOM
  • 81
  • 1
  • 1
3

This command is creating for me the same output like the ultra configuration with the ui. I have found it in the documentation under examples. 560MB to 29MB (binary data with a lot duplicate files)

7za.exe a output.7z ./input -mx
David
  • 505
  • 3
  • 8
2

I think you are looking for a tool like this:

https://axelstudios.github.io/7z/#!/

In this online tool, you set your settings and then you get correspondent command line options and parameters.

arn
  • 31
  • 1