I am currently running a computer which has access to only Windows.
I have to submit a folder after running tar -czf on it.
How can I do this in Windows, do I have any options?
I am currently running a computer which has access to only Windows.
I have to submit a folder after running tar -czf on it.
How can I do this in Windows, do I have any options?
If all you want is to create a tar.gz (also called tgz) file, then you can use 7Zip from http://www.7-zip.org/
To run like "tar -czf" you need to chain two 7z calls:
7z -ttar a dummy c:\my\path\* -so | 7z -si -tgzip a x.tgz
This creates a file x.tgz containing all data from c:\my\path\.
The -so redirects the output to stdout and the -si option picks that data up.
As of build 17063 (2017), Windows has tar.exe built-in (source). So you can directly use tar commands:
Creating a zip file:
tar -cf [output.zip] [folder/file_name]
Extracting a zip file:
tar -xf [file.zip]
Take a look at Tar for Windows.
The GNU Tar program provides the ability to create tar archives, as well as various other kinds of manipulation. For example, you can use tar on previously created archives to extract files, to store additional files, or to update or list files which were already stored.
The Win32 port can only create tar archives, but cannot pipe its output to other programs such as gzip or compress, and will not create tar.gz archives; you will have to use or simulate a batch pipe. BsdTar does have the ability to direcly create and manipulate .tar, .tar.gz, tar.bz2, .zip, .gz and .bz2 archives, understands the most-used options of GNU Tar, and is also much faster; for most purposes it is to be preferred to GNU Tar.
tar -czf creates a gzipped tar file, usually the extension .tar.gz or .tgz is used.
Windows has no built-in support for creating (or reading) tar files or gzipped files, and Microsoft offers no tools for this either.
This format can be created using, e.g., 7Zip; see for example this blog post: http://www.tmsnetwork.org/blog/creating-targz-archive-easily-windows (archive.org copy: apparently this blog disappeared). Many more tools could be used, see http://www.7zip.com/type/5/TAR (archive.org copy: apparently 7zip.com disappeared, to be replaced by 7-zip.org).
Windows has a tar command. Testing has shown some options are missing, while other options do seem be ignored or generate an error message. Below is the output from tar --help.
tar(bsdtar): manipulate archive files
First option must be a mode specifier:
-c Create -r Add/Replace -t List -u Update -x Extract
Common Options:
-b # Use # 512-byte records per I/O block
-f <filename> Location of archive (default \\.\tape0)
-v Verbose
-w Interactive
Create: tar -c [options] [<file> | <dir> | @<archive> | -C <dir> ]
<file>, <dir> add these items to archive
-z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma
--format {ustar|pax|cpio|shar} Select archive format
--exclude <pattern> Skip files that match pattern
-C <dir> Change to <dir> before processing remaining files
@<archive> Add entries from <archive> to output
List: tar -t [options] [<patterns>]
<patterns> If specified, list only entries that match
Extract: tar -x [options] [<patterns>]
<patterns> If specified, extract only entries that match
-k Keep (don't overwrite) existing files
-m Don't restore modification times
-O Write entries to stdout, don't restore to disk
-p Restore permissions (including ACLs, owner, file flags)
bsdtar 3.5.2 - libarchive 3.5.2 zlib/1.2.5.f-ipp
Below are some basic example commands for creation and extraction.
tar -ca[v]f archive-file.zip [--exclude pattern] [-C directory] file...
For example, to create the stuff.zip file containing the directory E:\a\b (including subdirectories), enter the following.
tar -caf stuff.zip e:\a\b\*
tar -ca[v]f archive-file.tar [--exclude pattern] [-C directory] file...
or
tar -c[v]f archive-file.tar [--exclude pattern] [-C directory] file...
For example, to create the stuff.tar file containing the directory E:\a\b (including subdirectories), enter the following.
tar -cf stuff.tar e:\a\b\*
tar -ca[v]f archive-file.tgz [--exclude pattern] [-C directory] file...
or
tar -cz[v]f archive-file.tgz [--exclude pattern] [-C directory] file...
For example, to create the stuff.tgz file containing the directory E:\a\b (including subdirectories), enter the following.
tar -czf stuff.tgz e:\a\b\*
tar -x[kmpv]f archive-file[.tar | .tgz | .zip] [--exclude pattern] [-C directory] [patterns]
For example to extract the contents (including subdirectories) of the stuff.tgz file to the directory E:\a\b , enter the following. Note, the p option was used to restore permissions (including ACLs, owner, and file flags).
tar -xpf stuff.tgz -C e:\a\b
Below are some specifications for the Windows I used for testing.
Windows Specifications
| Item | Value |
|---|---|
| Edition | Windows 10 Pro |
| Version | 22H2 |
| Installed on | 1/16/2025 |
| OS build | 19045.2965 |
| Experience | Windows Feature Experience Pack 1000.19041.1000.0 |
You can also download and install 7zip. http://www.7zip.org. With it, you can both unpack and pack many different compression types including gzip.
Make these steps:
Download libarchive https://sourceforge.net/projects/gnuwin32/files/libarchive/2.4.12-1/libarchive-2.4.12-1-setup.exe/download
Then"%programfiles(x86)%\gnuwin32\bin\bsdtar.exe" czf path_to_compressed_file path_to_folder
I think the most elegant way to do it would be to install Linux subsystem for Windows.
Please keep in mind that this is beta.
There are also lots of ways to get Linux functionality:
There are lots of tools and applications that do this.