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.

I'm new to Mac OS X and am not sure how to do this:

I have three directories. I want to create a tar/zip file of them so that I can attach them to an email.

Any ideas?

share|improve this question

4 Answers 4

up vote 30 down vote accepted

OSX ships with tar, so from the Terminal, you can simply do this:

tar czf archive_folder_name.tar.gz folder_to_copy

Replace archive_folder_name.tar.gz with whatever you want to call the newly created archive, and folder_to_copy with whatever is the name of the folder you want to archive.

share|improve this answer
1  
Personally, I'd use tar cjf for bzip instead of gzip (Smaller files) but that's just a personal preference I suppose. –  Matthew Scharley Sep 24 '09 at 23:45
    
If you're going for smaller files, then you'd not be after either of them; you could just use p7zip (7z). –  Nerdling Sep 25 '09 at 1:29
    
I tend to go for gzip first, maybe out of habit. To be honest, in most cases I'm not especially worried about trimming the size of the archive itself. It's a reasonable thing to care about, but given the huge size of most machines' hard drives, I don't find myself worrying about space much. If anything, the main reason that I bundle items any more is simply to improve the time factor when copying. OSX in particular seems to take exponentially long to copy lots of even very small files (like source directories) if you don't archive them. –  Telemachus Sep 25 '09 at 11:45

Ok Ok. It's very funny & silly.

But I think I found the option.

Right click on the folder that you want to compress.

Compress option is available.

share|improve this answer
    
This will zip the file with the built in Archive Utility. If you want to use tar you end up having to use the command line. (See Telemachus's answer for details on the command line) –  Chealion Sep 25 '09 at 1:22
    
Archive Utility creates zip archives, not tar gzip. –  Nerdling Sep 25 '09 at 1:30
    
I think Sagar has the best answer. The poster says "tar/zip", but that doesn't necessarily mean he's looking for a .tar.gz file, he's just looking for some way to compress a directory into a single archive so it can be attached to an email message. –  khedron Sep 25 '09 at 20:07

Well, other than GUI you can use console (or install some kind of compressing software like StuffixExpander or something like that if you don't like the default one or need more formats)

tar --help

tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.

share|improve this answer

If you are looking for a GUI solution, simply use the compress command fron the contextual menu.

If you are interested in command-line solutions, several options are possible.

You may of course use the tar command.

tar -zcvf archive.tar.gz folder

But if you are sharing archives, some people may prefer a zip file, that you could create with the zip command

zip -r archive.zip folder
share|improve this answer

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.