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.

9
  • 1
    Why do you consider 18GB of write to be an issue? Space constraints or… wear-rate paranoia?
    – Tetsujin
    Dec 30, 2020 at 18:36
  • 1
    @Tetsujin OPs mention of "write operations" indicates that is the case. Dec 30, 2020 at 19:03
  • @music2myear - I kind of guessed that, but I just wanted confirmation ;)
    – Tetsujin
    Dec 30, 2020 at 19:31
  • It's 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 :)
    – Basj
    Dec 30, 2020 at 19:43
  • 1
    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. // This operation in general is very feasible. However, you need a purpose-made program to do it.
    – Daniel B
    Dec 30, 2020 at 20:30

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.