Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any way to selectively prevent certain file types from compression in 7-zip, like in WinRAR?

I'm trying to compress a huge folder (many gigabytes), and I don't want the already-compressed files (e.g. ZIP files) to be re-compressed -- they should be stored without compression.

share|improve this question
    
Is there a specific reason (saving every little bit of processing time possible, reading them without having to bundle the 7z binary or re-implement LZMA, etc.) that you want to do this? Generally speaking, most compression tools I've run into tend to be smart enough to automatically store things uncompressed if they find a file responds poorly to an attempt to compress it further. –  ssokolow Sep 19 '11 at 2:38

3 Answers 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!)

share|improve this answer

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

share|improve this answer
    
Kind of a hassle but I guess that would work, thanks. –  Mehrdad Sep 24 '11 at 6:54

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.

share|improve this answer
    
The above command will not compress the txt files and add only the txt files to an existing archive. Before running the above command, an archive file should be created with the non-txt files. Not so easy if there are n different types of files. –  Praveen Sripati Sep 18 '11 at 9:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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