How to do "Files to store without compression" in 7-zip?

Solution 1:

Yes, it is possible to have different compression methods for different files within the same 7-Zip archive.

Use the command line version of 7-Zip with the -m parameter to specify the method as Copy, which means no compression.

Example :

7za a -m0=Copy tmp7.7z *.txt

For more info, see -m (Set compression Method) switch.

Solution 2:

Lets assume you have zip files and you have uncompressed txt files in your folder.

First step is to create a archive compressing txt files using following command.

you can use -m for setting levels of compression , this also depends on compression method you are using

Lets assume here to be default compression only

7z a compressed.7z *.txt -r 

You will get compressed.7z now.

The second step will be to copy the already compressed file to this archive or create a new archive

7z u compressed.7z -u!update.7z -mx0 *.zip 

There is further elaboration of update command here

And in case you have liberty to use graphical interface, the update can be done in a following way

enter image description here

Solution 3:

Technically, compressed files do not compress further, something about an entropy limit or such, I forget the details, but the most you'd ever get is less than 2% that I've seen.

Most good compressors check the compression and simply store uncompressible files since compressing then would add overhead and increase the size.

Of course, there's the work & time of looking at the file in the first place.

As discussed in other answers, performing multiple passes over your fileset is probably going to be the best solution and is easily scriptable.

Create the 7z archive and add everything BUT the compressed files in one pass, then append the pre-compressed files as non-compressed data. (I'd do it this way since the compressible stuff would then be at the beginning of the archive and the non-compressible all at the end. It would stream off drive faster since it's contiguous)

(used 'compress...' too much!)

Solution 4:

I created a PowerShell script that will quickly compress a directory by storing filetypes that are already compressed (like .zip files) without trying to re-compress them. It uses 7zip's command line interface and uses filename extensions in order to decide whether to compress or simply store any given file.

You can find the script here: https://gist.github.com/ivanatpr/5dea086172eab573ba71