posted by jwerner on Sunday, November 24, 2013 3:26 PM

Want to create tar.gz archives on Windows quickly? Check this batch script

If you need to create gzipped tar archives on Windows, you can use 7-Zip. However, this implies first creating a tararchive and second adding the tar archive to a gzarchive.

Here is how to do this in one step. We'll create a little batch file and integrate it into the Windows Explorer's Send To: context menu.

Download the 7-Zip commandline tool and extract the file 7za.exe in your user profile folder (something like C:\Users\USERNAMEon Windows 7).

In your user profile folder, create a new batch file targz.bat using the following code:

@echo off
rem Create a tar.gz archive with 7-zip commandline 7za
rem Author: Joachim Werner <>
rem Requirements: 7za.exe in the user dir (C:\Users\USERNAME)

echo Create a tar.gz archive
echo Directory: %1
cd %1\..

rem Path to 7za.exe:
set SEVENZA=C:\Users\jwerner\7za

rem get directory basename
set BASENAME=%~n1

rem path and filename for tar
set TAR=%cd%\%BASENAME%.tar

rem create tar
%SEVENZA% a -ttar %TAR% %1

rem create tar.gz
%SEVENZA% a -tgzip %TAR%.gz %TAR%

rem remove tar
del %TAR%



In the Windows Explorer, copy this batch file.

Find your Send To... folder. On Windows 7, this should be


In this folder, paste the copied batch file as a link.

Now to create a tar.gz archive of a folder and its content, you can right-click it and select Send To... \ targz.bat Link. A command prompt will open, create the file and list the folder and archive file.



No comments

Please enter the letters as they are shown in the image above.
Letters are not case-sensitive.

Add comment

Change Log

Created OnNov 24, 2013 3:26:40 PM CET
Created ByJoachim Werner (jwerner)
Updated OnNov 24, 2013 3:34:46 PM CET
Updated ByJoachim Werner (jwerner)