2

I'm working on archiving and compressing a lot of design elements and they are mixed in .zip and .rar files.

After tinkering and testing these settings seem to produce the best results for me:

enter image description here

I'm following this nice piece of code posted in this question and I'm trying to modify it to have the settings I want.

However, the .bat will not run.

This is the code I have:

for %%F in (*.rar) do ( "C:\Program Files\7-Zip\7z.exe" x -y -o"%%F_tmp" "%%F" * & pushd %%F_tmp & "C:\Program Files\7-Zip\7z.exe" a -y -r -t7z -m0=lzma2 -mx=9 -mfb=128 -md=512m -mmt:on ..\"%%~nF".7z * & popd & rmdir /s /q "%%F_tmp" )

Additionally is there a way to have this run on BOTH .zip and .rar out of the same .bat? Right now I have 2 versions.

3
  • 1
    Is there reason to cram it into one line? What does not work? To process both file types --> for %%F in (*.rar *.zip) do ...
    – LotPings
    Commented Oct 11, 2018 at 18:00
  • The batch file works fine for me, even in one line, but I get System error: The parameter is incorrect on the second 7zip command.
    – Worthwelle
    Commented Oct 11, 2018 at 18:02
  • @LotPings I'm new to command line scripting and I didn't know where to return. Commented Oct 11, 2018 at 18:07

1 Answer 1

2

The -mnt:on option is simply wrong, at least with my 7-Zip 18.05 (x64)

This batch:

:: Q:\Test\2018\10\11\SU_1365974.cmd
@Echo off
Set  z7="C:\Program Files\7-Zip\7z.exe"
Set "z7o=a -y -r -t7z -m0=lzma2 -mx=9 -mfb=128 -md=512m "

for %%F in (*.rar *.zip) do ( 
  %z7% x -y -o"%%F_tmp" "%%F" *
  pushd %%F_tmp
  %z7% %z7o% ..\"%%~nF".7z * ||(pause)
  popd 
  rmdir /s /q "%%F_tmp"
  Rem del "%%F"
)

(remove the Rem in front of del to delete the original archive file)
Produced these results on sample zip files mostly from an arduino installation.

> dir
 Datenträger in Laufwerk A: ist RamDisk
 Verzeichnis von A:\

2018-10-11  20:22    533.163            1802-064.7z
2018-01-27  15:38               535.890 1802-064.zip

2018-10-11  20:22    265.703            Adafruit_Circuit_Playground-1.6.9.7z
2017-10-21  18:06               408.442 Adafruit_Circuit_Playground-1.6.9.zip

2018-10-11  20:22    294.031            Adafruit_Circuit_Playground-1.8.0.7z
2018-03-09  19:39               472.998 Adafruit_Circuit_Playground-1.8.0.zip

2018-10-11  20:22     24.213            Adafruit_NeoPixel-1.1.3.7z
2017-11-30  20:26                36.399 Adafruit_NeoPixel-1.1.3.zip

2018-10-11  20:22     27.574            Adafruit_NeoPixel-1.1.6.7z
2018-03-09  19:39                40.682 Adafruit_NeoPixel-1.1.6.zip

2018-10-11  20:22     18.280            APA102-2.0.0.7z
2017-09-09  14:30                25.694 APA102-2.0.0.zip

2018-10-11  20:22        794            archive.7z
2018-09-24  14:13                 1.582 archive.zip

2018-10-11  20:22    128.390            ArduinoJson-5.13.1.7z
2018-03-09  19:40               242.718 ArduinoJson-5.13.1.zip

2018-10-11  20:22     17.001            AS_BH1750-master.7z
2017-12-15  15:17                31.034 AS_BH1750-master.zip

2018-10-11  20:22    489.473            avrdude-6.3.0-arduino9-i686-w64-mingw32.7z
2017-11-23  20:43               645.974 avrdude-6.3.0-arduino9-i686-w64-mingw32.zip

2018-10-11  20:22     31.008            Bridge-1.7.0.7z
2018-01-05  22:14                61.431 Bridge-1.7.0.zip

2018-10-11  20:22     14.761            DallasTemperature-3.7.6.7z
2017-09-09  14:30                27.378 DallasTemperature-3.7.6.zip

2018-10-11  20:22     14.811            DallasTemperature-3.8.0.7z
2018-03-09  19:40                27.988 DallasTemperature-3.8.0.zip
                   =========  =========
                        .7z        .zip
Cumulated size:    1.859.202  2.558.210
percent of the other     73%       138%
4
  • The mmt:on was to enable multithreading. Or is there another way to specify to use 8/4 cores? Commented Oct 11, 2018 at 19:06
  • If I read the help right -mmt[N] : set number of CPU threads, the proper use is -mnt8 similar to -mx9 in your options.
    – LotPings
    Commented Oct 11, 2018 at 19:09
  • So on mx9 it already would be using the max threads? Commented Oct 11, 2018 at 19:39
  • No the syntax -mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra) shows the [n] has to be replaced with the desired number. How the CPU threads relate to cores/affinity is a different question.
    – LotPings
    Commented Oct 11, 2018 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .