7-Zip command line: Extract silently/quietly

15

4

Possible Duplicate:
How to disable the output of 7-Zip?

I want to use 7z.exe from a command prompt to silently/quietly extract an archive. I do not want to use third-party scripts or APIs. Does 7-Zip have native support for quiet command-line extraction?

oscilatingcretin

Posted 2011-09-02T15:32:00.760

Reputation: 4 093

Question was closed 2011-09-03T19:46:08.610

7zip does not have silent mode. So, if you do not want to see the output, you can use "screen". start a new screen, then run the 7zip extraction command and then detach from the screen using "Ctrl-A + d". The screen will run in the background and you will not see the output. You can reattach with the screen when required to see whats happening. When completed, you can end the "screen" session. – bgth – 2017-01-17T05:16:35.367

Answers

6

7-Zip does not have an explicit "quiet" or "silent" mode for command line extraction.

A similar question over at Stack Overflow, Extracting a 7-Zip file "silently" - command line option, gives a possible solution using Python scripting code:

One possibility would be to spawn the child process with popen, so its output will come back to the parent to be processed/displayed (if desired) or else completely ignored (create your popen object with stdout=PIPE and stderr=PIPE to be able to retrieve the output from the child).

And then a similar question here on Super User, Redirect 7-Zip's command-line output to /dev/null on Windows when extracting a .7z file reports that the issue is mostly the output, and that by sending the output to NULL, you make the system run essentially silent:

Try doing this:

%COMSPEC% /c "%ProgramFiles%\7-Zip\7z.exe" ...

music2myear

Posted 2011-09-02T15:32:00.760

Reputation: 34 957

Note: I used the answer edited into my question by someone else. Putting > NUL at the end of my command line string works. I am just marking this as answer to increase my answer ration since I can't delete this post. – oscilatingcretin – 2011-09-07T14:45:11.427

I do the same thing sometimes. It's good to note, as you do, when that happens that it isn't quite the right answer, just the most convenient one. – music2myear – 2011-09-07T15:17:48.750

6

Yes, it does support command line use. Open a command prompt and navigate to the install folder (typically C:\Program Files\7-Zip) and type:

7z -h

Here is the result:

7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
       [<@listfiles...>]

<Commands>
  a: Add files to archive
  b: Benchmark
  d: Delete files from archive
  e: Extract files from archive (without using directory names)
  l: List contents of archive
  t: Test integrity of archive
  u: Update files to archive
  x: eXtract files with full paths
<Switches>
  -ai[r[-|0]]{@listfile|!wildcard}: Include archives
  -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
  -bd: Disable percentage indicator
  -i[r[-|0]]{@listfile|!wildcard}: Include filenames
  -m{Parameters}: set compression Method
  -o{Directory}: set Output directory
  -p{Password}: set Password
  -r[-|0]: Recurse subdirectories
  -scs{UTF-8 | WIN | DOS}: set charset for list files
  -sfx[{name}]: Create SFX archive
  -si[{name}]: read data from stdin
  -slt: show technical information for l (List) command
  -so: write data to stdout
  -ssc[-]: set sensitive case mode
  -ssw: compress shared files
  -t{Type}: Set type of archive
  -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
  -v{Size}[b|k|m|g]: Create volumes
  -w[{path}]: assign Work directory. Empty path means a temporary directory
  -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
  -y: assume Yes on all queries

So here is one example of a silent extraction:

7z x "C:\Path\To\File.zip" -y > nul

EBGreen

Posted 2011-09-02T15:32:00.760

Reputation: 7 834

3Doesn't answer the question. Where in your answer does it show silent/quiet mode? – NickG – 2016-08-22T09:11:27.157

Brilliant, I wanted to reduce spam during my build and piping to null was exactly what I needed. – Matt Klein – 2016-09-14T16:30:10.560

11He isn't asking about command options, he's asking specifically about silent operation from the command line. – music2myear – 2011-09-02T15:39:02.113

3Yep. I actually piped the results to a text file and searched for "quiet" and "silent" because I thought the answerer's example wasn't showing something. – oscilatingcretin – 2011-09-02T15:43:14.107

2Silent can mean different things to different people. I was assuming that the OP would read and apply the switches that they wanted, but I can certainly provide an example. – EBGreen – 2011-09-02T15:45:12.520