Store, list or extract files in an archive (originally on tape - Tape ARchiver).
BSD TAR.exe was added to Windows 10 (1803) from build 17063 or later.
Syntax List: TAR -tf archive-filename TAR -t [options] [patterns] Extract: TAR -xf archive-filename TAR -x [options] [patterns] Create: TAR -cf archive-filename [filenames...] TAR -c [options] [ file | dir | @archive | -C dir ] file, dir Update: TAR -rf archive-filename [filenames...] TAR -r [options] [ file | dir | @archive | -C dir ] file, dir The first option must be a mode specifier: -c Create -r Add/Replace -t List -u Update (alias for -r) -x Extract Common Options: -b # Use # 512-byte records per I/O block. -f filename Location of archive (default \\.\tape0). -v Verbose. -w Interactive. patterns If specified, only use entries that match. --help Help Create Options (when adding items to an archive): -a, --auto-compress (c mode only) Use the archive suffix to decide a set of the format and the compressions. -z Compress archive with gzip. -j Compress archive with bzip2. -J Compress archive with xz. --lzma Compress archive with lzma. -h, -L, --dereference (c and r modes only) All symbolic links will be followed. Normally, symbolic links are archived as such. With this option, the target of the link will be archived instead. --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. Extract Options: -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).
tar.exe is ported from FreeBSD and likely supports many or all of the BSD options, though these are not documented by Microsoft.
The tar utility exits with one of the following values:
0 All files were processed successfully.
1 An error occurred.
Create a new archive with zip format:
C:\> tar -a -cf archive.zip source.c source.h
Verbosely create a gzip archive, called 'sqlbackup.tar.gz', of all files matching the pattern *.sql:
C:\> tar.exe -cvzf C:\TARS\sqlbackup.tar.gz *.sql
List the content of the gzip archive 'C:\TARS\sqlbackup.tar.gz':
C:\> tar.exe -tvzf C:\TARS\sqlbackup.tar.gz
Create a new archive with restricted pax format and gzip compression:
C:\> tar -a -cf archive.tgz source.c source.h
Create a new archive with restricted pax format and bzip2 compression and uuencode compression:
C:\> tar -a -cf archive.tar.bz2.uu source.c source.h
Ignore the "-j" option, and create a new archive with restricted pax format and gzip compression:
C:\> tar -a -jcf archive.tgz source.c source.h
Compress files with an unknown suffix or no suffix, create a new archive
with restricted pax format and bzip2 compression:
C:\> tar -a -jcf archive.xxx source.c source.h
“Put three grains of sand inside a vast cathedral, and the cathedral will be more closely packed with sand than space is with stars” ~ James Jeans
COMPACT - Compress files or folders on an NTFS partition.
IEXPRESS - Create a self extracting ZIP file archive.
MAKECAB - Create .CAB files.
Compress-Archive - PowerShell.
Zip a file - using only built-in Batch/VBS commands (Superuser.com)