10

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?

radicaled
  • 2,369
  • 5
  • 30
  • 44

3 Answers3

9

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.

Tu.Ma.
  • 1,325
  • 10
  • 27
  • I'm currently doing that, but I'm keep getting the error. "C:\Program Files\7-Zip\7za.exe" a -ttar -so test.tar test" – radicaled Nov 13 '18 at 14:47
  • You are not using the command suggested in my answer. You are using the one in your question. Look carefully, there is a pipe followed by another 7z command. -so writes to stdout, that's why it keeps giving you the error. – Tu.Ma. Nov 14 '18 at 08:09
7

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 :)
1

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.

qwr
  • 9,525
  • 5
  • 58
  • 102