5

There is a feature of the WinRAR (for Windows) archiver I love a lot: it can be set up to skip trying to compress particular files (based on their extension (name pattern)) while including them into a compressed archive. When it comes to backing up a user home directory it saves tons of time to give up trying to compress mp3, jpg, zip, etc. files and just add them to a (non-solid) archive untouched while compressing text, xls, database etc. files being added.

Having switched to Linux I still strongly prefer non-solid compressing archivers (like zip and 7z, I mostly use 7z I have switched to even before switching to Linux) over traditional tar.gz for my own convenience reasons (tar.gz advocates use to say it is needed to save rights/ownership information and links but I don't use any in my non-system files).

But I miss the WinRAR's feature to skip specific files compression a lot. May you happen to be a 7z fan too, maybe you know the way to achieve the effect?

Anthon
  • 78,313
  • 42
  • 165
  • 222
Ivan
  • 17,368
  • 35
  • 93
  • 118
  • Cf. `-ax` http://7zip.bugaco.com/7zip/7zip_15_09/MANUAL/cmdline/switches/ar_exclude.htm – Nemo Dec 18 '15 at 12:51

2 Answers2

1

Normally this is done using tar but if you really want to skip compression set the compression level to 0.

Since I don't have the GUI and actually I don't use it you may have to write a script to do what you need for example I use PERL but you can do it any way you choose. This particular one will skip the jpg files.

my $archive = "/home/user/archive.zip";
for $file @filenames
{
    my $compression_level = 9;
    $compression_level = 0 if($file =~ /jpg$/);
    `7za a -tzip -mx=$compression_level $archive $file`;
}

You can probably get as sophisticated as you want with scripts but that's up to you.

Karlson
  • 5,845
  • 32
  • 51
0

I was just looking for the same and I realize this is an old question, but I think I've found a way.

Add the files to (i.e. update) the archive separately.

So for example first we add all the text files with best compression:

7z a archive.7z "*/*.txt" -mx9

Then update with all the mp3 files without compression:

7z u archive.7z "*/*.mp3" -m0=copy
laggingreflex
  • 230
  • 1
  • 2
  • 6