I noticed that there are people trying to come up with a way to extract .tar.gz files in one go on Windows. For instance, I was reading: How can I unzip a .tar.gz in one step (using 7-Zip)? While on a unix system this is trivial, with 7-zip on Windows this becomes a two-step process. There are of course a lot of solutions to this on Windows. The way I prefer to do it on Windows 7, is to have a context menu on Windows Explorer, right-click and extract the file in one go.
To do this first create the context menu entry:
- open the Registry Editor (regedit.exe)
- go to
- create a new key called
7-zip.gzcreate another key called shell
- under shell create another key called any name you like, e.g.
- provide a value for that last key, which is the text that will appear in the context menu of Windows Explorer when you right-click a .gz file. I named mine
- create another key this time called
- the value of this key must be (put all text in one line!!):
cmd /c @for %%f in ("%1") do ( @7z x -y %%~ff -o%%~dpf && @for %%i in (%%~nf) do ( @if %%~xi==.tar ( @7z x -y %%~fi -o%%~dpi && del %%~fi ) ) ) && pause
7-zip.gz registry key hierarchy should now look like his:
It is assumed that the command line utility of 7-zip (7z.exe) is available in your
PATH. If it isn’t add it.
Of course instead of squeezing the commands of extracting the files one after the other and then deleting the intermediate .tar file, you could write a more elaborate batch file and invoke that to handle the situation and add some error checking too. You could potentially do a similar process for
To use it open a Windows Explorer and locate your .tar.gz file, right-click and select the command you added. Mine looks like this:
Keep in mind that this command will not clutter your context menu, as it will only appear when you right-click a
.gz file. Also note that the script does some basic checking if the .gz file does have a .tar in it, but don’t expect it to be of commercial software quality, it’s just a quick hack!
The command looks cryptic, but the logic is actually extremely simple. Do you want the command explained?