Use Tar to Create Zip Archive Files in Windows 11

Published by Nyau Wai Hoe - Updated on

The tar command, which is very common in Unix and Linux systems for archiving and compressing files (also known as zipping), is also available in Windows 11 and Windows 10. It mainly helps you pack many files and folders into one file, called a tarball. In this guide, we’ll show you how to use the tar command in Windows to make ZIP archives.

Also see: How to Open or Extract .Gz, Tar.gz or .Tar File in Windows 11/10

How to Use Tar to Create Zip Archive Files in Windows 11

Check if you have tar installed in Windows 11

Before we start making ZIP files with the tar command, make sure you have all the needed tools on your Windows 11 or Windows 10 PC. Starting with Windows 10’s Fall Creators Update and also in Windows 11, the tar command is built-in and you can use it from Command Prompt or PowerShell. Below is how you can check if tar is on your computer and install it if it’s not.

  1. Open Command Prompt or PowerShell.
  2. Type tar --version and press Enter.
  3. If you see a version number, tar is already on your computer. If you get an error or the command doesn’t work, you need to install it.Check if tar is installed CMD Windows 11
  4. If tar is not on your computer, the simplest way to install it is by turning on the Windows Subsystem for Linux (WSL).
  5. Go to the Windows search bar, type “Turn Windows features on or off”, and click on it.
  6. In the Windows Features window, tick the box for “Windows Subsystem for Linux” and click OK.
  7. Restart your computer when asked.
  8. After restarting, you can install the Linux version you like from the Microsoft Store, like Ubuntu.WSL Ubuntu Windows 11
  9. Once you have WSL with your chosen Linux version installed, you can use tar by starting the Linux app from the Start menu.
  10. You can also use tar directly in Windows Command Prompt or PowerShell.

With tar ready to use on your Windows machine, you can now start making ZIP archive files. In the next part, we’ll go through the basic commands and how to use them.

Suggested read: How to Zip Files and Folders in Windows 11/10 Without Any Software

Create ZIP archives with tar command

Now that you have tar ready on your Windows computer, let’s see how to use it to make ZIP archive files. It’s quite simple and uses basic command line steps.

  1. Start Command Prompt or PowerShell, whichever you like more.
  2. Move to the folder where your files are by using the cd command. For instance, cd C:\Users\Username\Desktop\.Change directory to current folder CMD
  3. The basic way to make a ZIP file with tar is like this:
    tar -a -c -f archive_name.zip file_or_directory_to_compress
  4. Here, -a picks the ZIP format automatically, -c means create, and -f names the archive.
  5. To make a ZIP archive of a folder called MyFolder, the command would be:
    tar -a -c -f myarchive.zip MyFolder

    Use tar to create ZIP archive files in Windows 11

  6. This command makes a ZIP file named myarchive.zip with MyFolder inside.
  7. You can also pack several files or folders in one go:
    tar -a -c -f myarchive.zip file1.txt file2.txt MyFolder

    Zip archiving multiple files and directories with tar command

  8. This makes a ZIP file with file1.txt, file2.txt, and the MyFolder folder inside.
  9. To check if your files are correctly packed, you can list what’s in the ZIP file:
    tar -tf myarchive.zip

    Check tar zip archive files Windows

  10. This shows the files in myarchive.zip.

Pro tip: How to Split a File Into Multiple Files in Windows 11

In the next part, we’ll share some extra tips to make your ZIP archiving with tar even better.

Some tips for more efficient ZIP archiving with tar command

The basic tar command for making ZIP files is simple, but there are more options and tricks that can help you archive better and fit your needs.

  1. Usually, tar makes the ZIP file right where you are. To make the archive in a different place, add the path to the archive name. For example:
    tar -a -c -f C:\Archives\myarchive.zip MyFolder

    Creating tar zip archives in a specific directory

  2. Sometimes, you might not want to include certain files or folders in the archive. Use the --exclude option for this:
    tar -a -c -f myarchive.zip --exclude="file1.txt" MyFolder

    Excluding files and directories when using tar to create zip archives

  3. You can use wildcards (*) to pack files that match a certain pattern. For example, to pack all .txt files:
    tar -a -c -f textfiles.zip *.txt

    Tar create zip archives with wildcards

  4. If you want to see the files being packed, add the -v (verbose) option:
    tar -a -cvf myarchive.zip MyFolder

    Verbose in tar create zip archive Windows 11

  5. This will show each file as it’s added to the archive.
  6. After making an archive, it’s good to check if it’s all okay. Do this by:
    tar -tvf myarchive.zip

    Checking tar zip archive integrity

  7. This not only shows the contents but also checks if the files are fine.
  8. While -a picks ZIP compression by itself, you can choose other compression methods like gzip or bzip2 with -z or -j:
    tar -czf myarchive.tar.gz MyFolder
    tar -cjf myarchive.tar.bz2 MyFolder

    Tar create tar.bz2 compression in Windows 11

  9. Note that these commands make .tar.gz or .tar.bz2 files, not ZIP.
  10. For batch archiving multiple directories into separate archives, you can use a simple script or loop in the command line. For example, in PowerShell:
    foreach ($folder in Get-ChildItem -Directory) {
    tar -a -c -f "$($folder.Name).zip" "$folder"
    }

    How to batch archive zip files using tar in CMD Windows 11

Useful guide: Move All Files from Subfolders to Main Folder (Windows)

Create tar.gz and tar archives with tar command in Windows 11

Besides making ZIP files, the tar command in Windows can also make .tar.gz (tarball compressed with gzip) and .tar (uncompressed tarball) archives. These types are very common in Unix and Linux systems and are useful for many things, like backing up and sharing software.

Create a tar.gz archive

  1. To make a .tar.gz archive, use the -z option for gzip compression. The basic command looks like this:
    tar -czf archive_name.tar.gz file_or_directory_to_compress
  2. Here, -c means create, -z applies gzip compression, and -f names the archive file.
  3. To compress a folder called MyFolder into a .tar.gz archive, the command is:
    tar -czf myfolder.tar.gz MyFolder

    How to create tar.gz archive files in Windows 11 CMD

Create a tar archive

  1. Making an uncompressed tar archive is simple. Just leave out the compression option (-z for gzip or -j for bzip2). The command goes like this:
    tar -cf archive_name.tar file_or_directory_to_compress
  2. To pack MyFolder into a .tar file, use:
    tar -cf myfolder.tar MyFolder

    Use tar command to create tar file in Windows 11

Some other options

  • Just like with ZIP archiving, you can use the -v (verbose) option to see the files being added to the archive.
  • The --exclude option works the same way as with ZIP files, letting you leave out specific files or folders.
  • Use tar -tf archive_name.tar.gz or tar -tf archive_name.tar to list what’s in your .tar.gz or .tar archive.Check the content of a tar archive file in CMD

Nyau Wai Hoe
Nyau Wai Hoe is the Founder and Chief Editor of WindowsDigitals.com. With a degree in software engineering and over 12 years of experience in the tech support industry, Nyau has established himself as an expert in the field, with a primary focus on the Microsoft Windows operating system. As a tech enthusiast, he loves exploring new technologies and leveraging them to solve real-life problems.

Share via
Copy link