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

后端 未结 14 2282
南笙
南笙 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:55

    I just came across this when searching for the same, but I solved it myself! Assuming the command is processed with Windows / DOS, a simpler solution is to change your command to:

    7z.exe -o some_dir x some_archive.7z > nul
    

    That is, direct the output to a null file rather than the screen.

    Or you could pipe the output to the DOS "find" command to only output specific data, that is,

    7z.exe -o some_dir x some_archive.7z | FIND "ing archive"
    

    This would just result in the following output.

    Creating archive some_archive.7z

    or

    Updating archive some_archive.7z**


    My final solution was to change the command to

    ... some_archive.7z | FIND /V "ing  "
    

    Note double space after 'ing'. This resulted in the following output.

    7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
    
    Scanning
    
    Updating some_archive.7z
    
    
    Everything is Ok
    

    This removes the individual file processing, but produces a summary of the overall operation, regardless of the operation type.

提交回复
热议问题