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).

If 7zip were smart, it would do it in one step by default, since 99.99% of the time that's what the user wants to do. In fact, this is WinRar's default operation.
–
davrDec 7 '09 at 20:35

3

@davr: 7-zip is an open source effort; feel free to request this feature. this is how v4.65 operates; i haven't tried the newer v9.x alphas, so it may already be included.
–
quack quixoteDec 7 '09 at 20:52

new user to 7z myself, i was interested in knowing if this was possible as well.
–
Roy RicoDec 8 '09 at 2:39

1

Note that the "in one step" instructions doesn't actually do it in one step, it actually decompresses the .gz into a temporary folder, then opens the .tar file in 7-zip. When the archives are small enough, it's hardly noticeable, but it's very noticeable on large archives. Just thought that deserved clarification.
–
naaskingOct 25 '13 at 18:29

You're using Windows XP, so you should have Windows Scripting Host installed by default. With that being said, here's a WSH JScript script to do what you need. Just copy the code to a file name xtract.bat or something along those lines (Can be whatever as long as it has the extension .bat), and run:

xtract.bat example.tar.gz

By default, the script will check the folder of the script, as well as your system's PATH environment variable for 7z.exe. If you want to change how it looks for stuff, you can change the SevenZipExe variable at the top of the script to whatever you want the executable name to be. (For instance, 7za.exe or 7z-real.exe) You can also set a default directory for the executable by changing SevenZipDir. So if 7z.exe is at C:\Windows\system32\7z.exe, you'd put:

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:

@echo off
setlocal enabledelayedexpansion
rem Ensure 7z.exe is in your path... ie. set PATH=%PATH%;C:\Program Files\7-Zip
rem Loop through all commandline args - the tar.gz files
for %%i in (%*) do (
rem Remove .gz
set j=%%~dpni
rem Remove .tar
for %%k in (!j!) do set k=%%~dpnk
rem I'm sure there's other ways to strip the extension/s,
rem but this works for .tar.gz and .tgz which is all I need.
rem Extract without an intermediate .tar
7z x "%%i" -so | 7z x -aoa -si -ttar -o"!k!"
)