Extracting a 7-Zip file “silently” - command line option

后端 未结 14 2297
南笙
南笙 2021-02-06 23:19

I want to extract a 7-Zip archive in a Python script. It works fine except that it spits out the extraction details (which is huge in my case).

Is there a way to avoid t

相关标签:
14条回答
  • 2021-02-06 23:59

    in hex editor find copyright and replace it's value with 0000 https://imgur.com/a/ZJswkyq

    0 讨论(0)
  • 2021-02-07 00:01

    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).

    0 讨论(0)
  • 2021-02-07 00:04

    To show just the last 4 lines...

    7z x -y some_archive.7z | tail -4
    

    gives me:

    Everything is Ok
    
    Size:       917519
    Compressed: 171589
    

    The switch -y is to answer yes to everything (in my case to override existing files).

    0 讨论(0)
  • 2021-02-07 00:08

    On Unix-like operating systems (Linux, BSD, etc.) the shell command 7z ... >/dev/null will discard all text written by 7z to standard output. That should cover all the status/informational messages written by 7z.

    It seems that 7z writes error messages to standard error so if you do >/dev/null, error messages will still be shown.

    0 讨论(0)
  • 2021-02-07 00:12

    The | FIND is a good alternative to show what happened without displaying insignificant text.

    0 讨论(0)
  • 2021-02-07 00:15

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

    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).

    Otherwise Try doing this:

    %COMSPEC% /c "%ProgramFiles%\7-Zip\7z.exe" ...
    
    0 讨论(0)
提交回复
热议问题