How to create tar file with 7zip

Viewed 26525

I'm trying to create a tar file on windows using 7zip.

Most of the documents I found said to do something like this:

7z a -ttar -so dwt.tar dwt/

But when I tried to run it I got this error:

Command Line Error: I won't write compressed data to a terminal

I'm currently using 7-Zip [64] 16.04

Any idea?

3 Answers

On Linux:

tar cf - <source folder> | 7z a -si <Destination archive>.tar.7z

from here

On Windows:

7za.exe a -ttar -so archive.tar source_files | 7za.exe a -si archive.tgz

from here.

I managed to do that making simply, with 7zip installed:

  • Right click on the folder you want to compress
  • Choose -7zip/add to file
  • Once there, on the new screen, on file type, you can choose 7z/tar/wim/zip
  • Choose tar, and there you go :)

From the manpage:

   -so    Write data to stdout (e.g. 7z x -so directory.tar.7z | tar xf -)

It does what you told it to. 7z can guess archive format from the file extension so it's enough to use

7z a archive.tar input/

To further compress as gzip you can use a pipe and a combination of stdin and stdout flags like in Tu.Ma.'s answer.

Related