How can I unzip a .tar.gz in one step (using 7-Zip)?

I am using 7-Zip on Windows XP and whenever I download a .tar.gz file it takes me two steps to completely extract the file(s).

  1. I right-click on the example.tar.gz file and choose 7-Zip --> Extract Here from the context menu.
  2. I then take the resulting example.tar file and the right-click again and choose 7-Zip --> Extract Here from the context menu.

Is there a way through the context menu to do this in one step?


Solution 1:

Not really. A .tar.gz or .tgz file really is two formats: .tar is the archive, and .gz is the compression. So the first step decompresses, and the second step extracts the archive.

To do it all in one step, you need the tar program. Cygwin includes this.

tar xzvf foobaz.tar.gz

; x = eXtract 
; z = filter through gZip
; v = be Verbose (show activity)
; f = filename

You could also do it "in one step" by opening the file in the 7-zip GUI: Open the .tar.gz file, double click the included .tar file, then extract those files to your location of choice.

There's a long running thread here of people asking/voting for one-step handling of tgz and bz2 files. The lack action thus far indicates it's not going to happen until someone steps and contributes meaningfully (code, money, something).

Solution 2:

Old question, but I was struggling with it today so here's my 2c. The 7zip commandline tool "7z.exe" (I have v9.22 installed) can write to stdout and read from stdin so you can do without the intermediate tar file by using a pipe:

7z x "somename.tar.gz" -so | 7z x -aoa -si -ttar -o"somename"

Where:

x     = Extract with full paths command
-so   = write to stdout switch
-si   = read from stdin switch
-aoa  = Overwrite all existing files without prompt.
-ttar = Treat the stdin byte stream as a TAR file
-o    = output directory

See the help file (7-zip.chm) in the install directory for more info on the command line commands and switches.

You can create a context menu entry for .tar.gz/.tgz files that calls the above command using regedit or a 3rd party tool like stexbar.

Solution 3:

Starting with 7-zip 9.04 there is a command-line option to do the combined extraction without using intermediate storage for the plain .tar file:

7z x -tgzip -so theinputfile.tgz | 7z x -si -ttar

-tgzip is needed if the input file is named .tgz instead of .tar.gz.

Solution 4:

Starting from Windows 10 build 17063, tar and curl are supported, therefore it is possible to unzip a .tar.gz file in one step by using tar command, as below.

tar -xzvf your_archive.tar.gz

Type tar --help for more information about tar.