You are here

Creating a .tar.gz file with 7-Zip

7-Zip - Creating a tar.gz file - Part 1I'm in the process of bringing my MyMiniCity Dynamic Signature script to SourceForge. While creating the download archives, I came across a very simple and yet very interesting question:

How do I create a ".tar.gz" file using 7-Zip on Windows?

On Linux, I would simply run:

tar cfz archive.tar.gz folder

When using 7-Zip on Windows, this process is a little bit more complicated.

As a GZIP compressed archive can contain only one file, 7-Zip won't offer you GZIP compression if you try to compress a folder or multiple files at once. When you choose TAR, you can't select any compression algorithm.

7-Zip - Creating a tar.gz file - Part 2The trick is, that you have to create a TAR archive first. You can then put that single TAR file into 7-Zip and it will finally offer you the ability to compress that file using GZIP.

The result is an archive with the .tar.gz extension which is exactly what you wanted to do.

That's another example how something that needs several mouse clicks on Windows needs a single line on a Linux shell.

Comments

Andreas Schipplock's picture

On windows I'm using IZArc (http://izarc.org) which is quite good and free, too but you know that already, I believe :).

Chi-Yu's picture

I'm actually happy with 7-Zip. It integrates into the context menu, supports all the formats that I use and it's free.

Sean Wolf's picture

thanks for the 7zip tip. learn something new everyday =)

Alberto's picture

Thanks!

Nik's picture

When you run that one-line command on Linux, you're actually doing the same thing.

tar cfz archive.tar.gz folder

In that command, you are 'c'reating a tarball archive, then 'z'ipping the tarball to save on space, and then outputting it to a 'f'ile.

Why is that required? Simply because a tarball is a blob of files joined into one. TAr stands for Tape Archive, and it represents a contiguous stream of files saved onto a tape drive. TAr doesn't have any compression method on its own.

Conversely, gzip has a great compression method, but like you say it only supports zipping one file at a time (eg, it doesn't have a file table). That's why you tarball the files first, and then zip them.

The upshot of this means you need to run two processes in 7-zip. And I agree with you – it should be one – but at least the above explains why.

Just a random user's picture

Thanks. You saved my day.

Just a random user's picture

Wow, thanks for the help.
I'm surprised that 7zip doesn't offer a one-click .tar.gz but thanks to you it's not a problem.

Just a random user's picture

That was very good hint, thank you very much:)

Tarwin's picture

Thanks mate very useful!

Just a random user's picture

Hey MF!
It's not same result because on tar.gz created on windows when i extract the active i obtain the file!

Whit this method i obtain a file .tar inside a file gz!! useless!

Chi-Yu's picture

Hey mate. It's not my fault that you fail to handle your packer software or even understand the concept of tar files. So before you shout at people for providing "useless" information, I suggest you better educate yourself and learn how to use the information which was given to you because everything else just makes you look dumb. :)

Ayesh's picture

I used to to compress all files in the server itself but I did have 7ZIP installed on my PC. Didn't knew that tiny software could do tar.gz as well :) Thanks!

ank pro's picture

thats great trick. It works fine, thanks

Ankit's picture

Thanks for nice post.. Keep it up..

Add new comment