1. Home
  2. Windows Tips
  3. Use tar on windows 10

How To Use Tar On Windows 10

Both Linux and macOS can create and extract a compressed archive file out of the box. As of Windows 10 build 17063 though, Tar is now packaged in the OS by default. This gives users a way to compress files without installing additional apps however, Tar only has a command line interface on Windows 10 and it cannot create or extract ZIP files. Those are its limitations. Here’s how to use Tar on Windows 10.

Tar On Windows 10

Check your Windows 10 build number to make sure you have build 17063 or later.

Compress Files

To compress files and folders, you need to run the following command.

Syntax

tar -cvzf archive name.tar path to folder to compress

Example

tar -cvzf archive.tar "C:\Users\fatiw\Desktop\My Account Info"

The output file will be saved to the same directory that you’re in. For example, if you ran the above command in your user folder, that’s where the archive will be saved. You can cd to a different folder, and create the archive there. If the file name that you want to give the .tar file or the path to the folder or file you want to compress contains spaces, make sure you enclose it in double quotes.

Extract

To extract a Tar file, you need to run the following command.

Syntax

tar -zxvf archive name.tar -C path to extraction location

Example

tar -zxvf archive1.tar -C "D:\Apps"

About Extraction And Compression

There is a small difference between extraction and compression using Tar on Windows 10. When you compress a file or folder, the compressed file is saved to the directory you’re currently in. This means that you have to be careful which folder you cd into. Alternatively, you can specify in the command where you want to save the Tar file.

Syntax

tar -cvzf "path and name to archive.tar" "path to folder to compress"

Example

tar -cvzf "C:\Users\fatiw\Desktop\My Account Info\my_archive.tar" "C:\Users\fatiw\Desktop\My Account Info"

With extraction, you have to specify where the folder is extracted to however you can extract it from any directory. You do not have to cd into the folder the Tar file is in to execute the command.

You can read up on other commands that the Tar program supports. It’s not the easiest way to compress files and folders and users will likely still go for third-party apps that offer a GUI over clunky command prompt commands simply because they’re easier to use.

9 Comments

  1. What would the syntax be to do both of these with just 1 tar command:
    Extract to a certain folder.
    Create that folder if it doesn’t already exist

  2. Unfortunately, Windows’s tar supports only the most basic operations. No “–delete”, for example.

  3. Thanks! This was helpful to me as we could not extra a unix .tar file in Win10 using common tools like 7zip and WinRAR but was able to use the tar -zxvf command line and it worked like a charm.

  4. Does not work for me. Gives me a “could not chdir to *targetdirectory*”, no matter what value for *targetdirectory* I choose.

    • the command itself does not create the directory. that error is when you’re asking it to extract to a directory that doesn’t exist. Either create the directory first or change the command to go up one level.

    • You get this message if the directory does not exist. If it exists, the extract works fine.

      My environement : Win 10 out of the box with no special setup for tar.

      I used a local directory c:\temps with following syntax : c:\temp>tar -zxvf “Mila.tar” -C “c:\temp\mila”

    • To use tar to extract a zip file:
      The target directory must exist
      When you specify the option “-C” the “C” must be capitalized.
      You must have “Write” permissions to the target directory.
      The target directory can’t end in a slash “\”

      Examples:
      tar -xf “\\ServerName\ShareName\PathToZipFile\ZipFile.zip” -C “c:\users\myusername\downloads”

      tar -xf “c:\users\myusername\downloads\ZipFile.zip” -C “c:\users\myusername\downloads”

  5. “Windows cannot compress files and folders out of the box and users have to download apps to add this feature.”

    Windows has been able to natively compress and decompress zip files since version 7. Zip is so much more common than tar. It is so universal that you can download projects from github as zip files without installing git. 7z is probably the second or third most common compression.

    It is useful to know that tar usually goes hand in hand with something like gzip. Historically, tar was used to take all of the files and directories and put them into one file(back when tar stood for Tape ARchive, then compressed with gzip, which is why you have files with names like ‘mybackup.tar.gz.’ Creating a tar file from a directory called ‘my-files’ with 2 100k files would result in a my-files.tar file of a little over 200k. 100k * 2 plus overhead, checksums, etc. Then the tar file was compressed with gzip. if those were text files, my-files.tar.gz might be as low as 20k in size, depending on the level of compression and the file contents.