7zip Exclude from compression but still store

Help
2010-01-21
2015-11-25
  • Robert Readman

    Robert Readman - 2010-01-21

    When backing up with 7zip i.e.

    tar cvf - /my/backups/ | 7za a -si -t7z backup.tar.7z -mx=9

    In backups I have lots of files and folders, around 40% of them are .jpg files and .pdf files. I would still like to backup these files however they takeup alot of time to try compress only to shave a few bytes.
    Is there away to exclude the *.pdf and *.jpg from being compressed, however still store them in the .7z file.

    Many Thanks,

    Robert Readman.

     
  • Marcin Zajaczkowski

    You can use two phase compression. The first to store everything with exclusion on selected extension, the second to add to the same archive previously excluded files (with no compression). -ms=on is an optional flag.
    $ 7za a -mx=8 -ms=on foo-2phases.7z foo/ -xr\!foo/*.jpg -xr\!foo/*.png
    $ 7za a -mx=0 foo-2passes.7z -ir\!foo/*.jpg -ir\!foo/*.png

    It can be wrapped with a script containing a list of commonly known extensions which don't compress well, but nevertheless I thing there could be a switch in 7-zip/p7zip to make it in one command. That mechanism could have predefined (hardcoded) list of that extensions which could be overridden by an user using for example system variable.

    Something like:
    $ export P7ZIP_STORE_EXT="jpg gif 7z …"
    $ 7za a -mx=8 -mse=on foo.7z foo/

    Marcin

     
  • luminoso

    luminoso - 2011-06-21

    Could you please explain a little better you to use the variable? I have a big list that can greatly improve my backup speed!

    P7ZIP_STORE_EXT=".3fr,.3gp,.7z,.aac,.ai,.ape,.arj,.arw,.asd,.asf,.avi,.bay,.bin,.bz2,.cab,.cap,.cr2,.crw,.dat,.dcr,.dcs,.djvu,.dll,.dmg,.dng,.drf,.eip,.erf,.exe,.fff,.flac,.flv,.gif,.gzip,.iiq,.iso,.k25,.kdc,.m4a,.mef,.mkv,.mos,.mov,.mp4,.mp4v,.mpc,.mrw,.msi,.nef,.nrg,.nrw,.ogg,.orf,.pdf,.pef,.psd,.ptx,.pxn,.R3D,.raf,.raw,.rmbv,.rw2,.rwl,.rwz,.sr2,.srf,.sqx,.tar.bz2,.tar.gz,.tif,.tiff,.vdi,.vmdk,.vob,.wav,.webm,.wma,.wmv,.x3f,.r01,.r02,.r03,.r04,.r05,.r06,.r07,.r08,.r09,.r10,.r11,.r12,.r13,.r14,.r15,.r16,.r17,.r18,.r19,.r20,.r21,.r22,.r23,.r24,.r25,.r26,.r27,.r28,.r29,.r30,.r31,.r32,.r33,.r34,.r35,.r36,.r37,.r38,.r39,.r40,.r41,.r42,.r43,.r44,.r45,.r46,.r47,.r48,.r49,.r50,.zip,.001,.002,.003,.004,.005,.006,.007,.008,.009,.010,.011,.012,.013,.014,.015,.016,.017,.018,.019,.020,.021,.022,.023,.024,.025,.026,.027,.028,.029,.030,.031,.032,.033,.034,.035,.036,.037,.038,.039,.040,.041,.042,.043,.044,.045,.046,.047,.048,.049,.050,.mpeg,.jpg,.jpeg,.mp3,.nrg"
    

    export the variable is enough?

     
  • ivanatpr

    ivanatpr - 2015-11-25

    I couldn't find an easy way to do this so 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

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks