Zip file using terminal - Too big size

Discussion in 'Mac Basics and Help' started by Mattijah, Mar 31, 2014.

  1. Mattijah, Mar 31, 2014
    Last edited: Mar 31, 2014

    Mattijah macrumors newbie

    Joined:
    Mar 31, 2014
    #1
    Hi, I have tried to zip folder using terminal. To be more specific I use this command:

    Code:
    zip -r zippedFolder Folder
    The problem is that archive that I get is too big. For example I am trying to zip folder that has approx. 255 MB. This command will make archive that has about 253 MB ,but when I try to zip the same folder using the right click & compress I will get archive which is 183 MB big... How can I get the same size using terminal? Thanks
     
  2. maflynn Moderator

    maflynn

    Staff Member

    Joined:
    May 3, 2009
    Location:
    Boston
    #2
    You're using two different compression applications. You have the terminal command which is probably a bit older and less effecient and Finder's compression routines which are more aggresive.

    If you want to maximize your ability to compress files, I recommend you use 7-zip
     
  3. Mattijah thread starter macrumors newbie

    Joined:
    Mar 31, 2014
    #3
    Can I use somehow Finder's compression in Terminal?
     
  4. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #4
    From the zip man page here, it looks like there are some options to control compression.

    Code:
    -Z cm
           --compression-method cm
                  Set the default compression method.  Currently the main methods supported by zip are store and
                  deflate.  Compression method can be set to:
    
                  store  -  Setting the compression method to store forces zip to store entries with no compres-
                  sion.  This is generally faster than compressing entries, but results  in  no  space  savings.
                  This is the same as using -0 (compression level zero).
    
                  deflate  -  This is the default method for zip.  If zip determines that storing is better than
                  deflation, the entry will be stored instead.
    
                  bzip2 - If bzip2 support is compiled in, this compression method also becomes available.  Only
                  some  modern unzips currently support the bzip2 compression method, so test the unzip you will
                  be using before relying on archives using this method (compression method 12).
    
                  For example, to add bar.c to archive foo using bzip2 compression:
    
                         zip -Z bzip2 foo bar.c
    
                  The compression method can be abbreviated:
    
                         zip -Zb foo bar.c
    
     
  5. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #5
    You can add a 0-9 which affects the speed of the compression, where -9 is the slowest but most aggressive compression (-6 is default). You can also change compression method with the -Z flag, perhaps try to experiment with these settings.
     
  6. hiddenmarkov macrumors 6502a

    Joined:
    Mar 12, 2014
    Location:
    Japan
    #6
    what are your size needs for the compressed files?


    YOu can try out different compressors (and thier associated algoryhthms). Or since you don't seem to be scared of command line Rar for mac os can be an option (if not looking for just free options).

    Rar can compress decent for just one file. It can also if called up with certain command line options break your file up into several smaller rar files. If so inclined you could break up that 255mb file into however many 10mb rar files it compresses and breaks them down to. Not sure if other more .zip like apps can do that but worth a looking into if so maybe.

    RAR for mac is only command line though. Not sure if your example is a rare use and you favor gui based more.
     
  7. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #7
    All non-destructive compressors works by statistic analysis on frequency of content, what works best depends on the content. Other included command line compression on OS X is gzip and bzip2. Gzip uses Lempel-Ziv (same as 7zip).
     
  8. hiddenmarkov macrumors 6502a

    Joined:
    Mar 12, 2014
    Location:
    Japan
    #8

    which leads to a question for the op. OP, what is in the folder you are compressing?

    If heavy in jpeg file content for example you will not see stunning results in compression. What you have for your export settings at time of export is about as small a file as its going to get at that point.

    Compressors will wrap them up in the nice zip file to make it easier to ship off 10 pics in one folder vice 10 attachments. But that will be about it.
     
  9. Mattijah thread starter macrumors newbie

    Joined:
    Mar 31, 2014
    #9
    As I said above if I use right click & compress there is quite big difference. The folder contains zip archives, text files, images, psd, .sqlite... Basically several different things.

    Anyway, I have tried this command:

    Code:
    tar -cvzf folder.tar.gz folder
    And now I am getting I think exactly the same size as using right click & compress. Difference is only that a archive will be .tar.gz instead of just. zip
     

Share This Page