2

Every now and then, I receive a download link for a 6 GB .zip data archive that I'd like to:

  • download

  • unzip

  • recompress with 7z, with a password

I'd like to avoid using temporary files for each step, because it would use ~ 18 GB of write operations on my SSD, whereas only 6 GB are necessary at the end.

On Linux, it would probably be wget ... | unzip ... | 7z ... with pipes.

How to do this on Windows?


Note: this question is linked to Make 7-Zip extract an archive directly to a directory but not a duplicate, because the linked question only covers the "7z temp" part of the question, whereas I'm speaking about a download+unzip+7z chain.
Also I'm looking for a command-line solution, and not a drag'n'drop GUI solution like Make 7-Zip extract an archive directly to a directory.

Basj
  • 2,143

1 Answers1

2

The following command-line solution avoids temporary files for decompression/compression, and works on Windows. It uses -so and -si stdout/stdin flags of 7z.

7z e -so -r Takeout20201231_0941.zip *.mbox | 7z a -si -pSECRET -mhe=on -mx=2 Takeout20201231_0941.7z

Note that there is only 1 match for *.mbox in my original archive, so there is only one file to be decompressed / compressed.

With multiple files, it would more complex, as noted by @DanielB in his comment:

This operation is a bad fit for pipes or the like. You cannot really pipe multiple files around, because it’s not just data. They also have names.


Lastly, piping the download of the original ZIP directly to 7z e wouldn't be possible because ZIP files can't be stream-decompressed: they often have an index at the end of the file, thus requiring the whole file first before starting to decompress.

For this, we can quickly create a RAM disk X:\ with OSFMount:

osfmount.com -a -t vm -m X: -s 8G -o format:ntfs
Basj
  • 2,143