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

后端 未结 14 2275
南笙
南笙 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

    Expanding on @Matthew 's answer and this answer https://superuser.com/questions/194659/how-to-disable-the-output-of-7-zip I'm using FINDSTR instead of find so I can chain multiple lines to exclude and blank lines as well:

    7za.exe a test1.zip .\foldertozip | FINDSTR /V /R /C:"^Compressing  " /C:"Igor Pavlov" /C:"^Scanning$" /C:"^$" /C:"^Everything is Ok$"
    
    • /V: exclude
    • /R: regex
    • /C:"^Compressing " : begining of line, Compressing, 2 spaces
    • /C:"^Scanning$" : the word Scanning on its own on a line (begining/end)
    • /C:"^$" : a begining and end without anything in between, ie, a blank line

    I'm using /C so that a space is a space, otherwise it's a separator between multiple words to exlude as in this simpler version:

    FINDSTR /V "Compressing Pavlov Scanning Everytyhing"
    

    (the same caveats exist, if the wording changes in a new version, or if a useful line starts with the word "Compressing ", it will not work as expected).

提交回复
热议问题