Menu

7-zip list output to file

2010-02-09
2023-01-18
  • Jac Messerschmidt

    How to output the list produced by 7-zip to a file when in command line mode? I've tried the -o and -so switches, but that only produces errors. I'm running the commandline version 7za465 on Windows XP.

     
  • fernando

    fernando - 2010-02-09

    Try…

    7z l archive.7z >output.txt
    
     
  • Jac Messerschmidt

    Sorry ikxcsshcm7, that didn't work. Even when I provided an empty file, nothing was written to it. I also added a space after > but that also produced nothing. Any other ideas?

     
  • fernando

    fernando - 2010-02-11

    What is the command line you are using to output the list produced by 7-zip to the screen?

     
  • Jac Messerschmidt

    I use a vanilla "7za l file.7z" to get screen output, no problem. But if you add anything to that (e.g. > output.txt) it ignores you. If you try to use -o or -so switches it gets real nasty and hangs or even throws up an error 7!

     
  • fernando

    fernando - 2010-02-11

    The only way to get output to a file is to use redirection…

    $ :: Showing Directory:
    $ DIR/B
    file.7z
    $ :: Listing Archive Contents with 7za:
    $ 7za L file.7z
    7-Zip (A) 4.65  Copyright (c) 1999-2009 Igor Pavlov  2009-02-03
    Listing archive: file.7z
    Method = LZMA
    Solid = +
    Blocks = 1
    Physical Size = 384308
    Headers Size = 258
       Date      Time    Attr         Size   Compressed  Name
    ------------------- ----- ------------ ------------  ------------------------
    2006-02-28 06:00:00 ....A        55776       384050  chimes.wav
    2006-02-28 06:00:00 ....A        97016               chord.wav
    2006-02-28 06:00:00 ....A        80856               ding.wav
    2006-02-28 06:00:00 ....A       119384               notify.wav
    2006-02-28 06:00:00 ....A        25434               recycle.wav
    2006-02-28 06:00:00 ....A         1192               start.wav
    2006-02-28 06:00:00 ....A       171100               tada.wav
    ------------------- ----- ------------ ------------  ------------------------
                                    550758       384050  7 files, 0 folders
    $ :: Listing Archive Contents with 7za and Redirecting Output to File:
    $ 7za L file.7z >output.txt
    $ $ :: Showing Directory Again:
    $ DIR/B
    file.7z
    output.txt
    $ :: Displaying Contents of Output File:
    $ TYPE output.txt
    7-Zip (A) 4.65  Copyright (c) 1999-2009 Igor Pavlov  2009-02-03
    Listing archive: file.7z
    Method = LZMA
    Solid = +
    Blocks = 1
    Physical Size = 384308
    Headers Size = 258
       Date      Time    Attr         Size   Compressed  Name
    ------------------- ----- ------------ ------------  ------------------------
    2006-02-28 06:00:00 ....A        55776       384050  chimes.wav
    2006-02-28 06:00:00 ....A        97016               chord.wav
    2006-02-28 06:00:00 ....A        80856               ding.wav
    2006-02-28 06:00:00 ....A       119384               notify.wav
    2006-02-28 06:00:00 ....A        25434               recycle.wav
    2006-02-28 06:00:00 ....A         1192               start.wav
    2006-02-28 06:00:00 ....A       171100               tada.wav
    ------------------- ----- ------------ ------------  ------------------------
                                    550758       384050  7 files, 0 folders
    $
    
     
  • Jac Messerschmidt

    Thanks, ikxcsshcm7.  Your suggestion still does not not work, of course, because of that pesky "7za L file.7z >output.txt" call that flatly refuses to do anything. I was hoping there was a simple in-line command that could do the job. Perhaps that's a nice challenge for Mr Pavlov to get his teeth into.

    As is is, I devised a simple workaround in Delphi and that works fine although it's not very elegant or efficient. But it works.

     
  • Konstantin

    Konstantin - 2022-10-27

    Hello!

    Use 7za.exe instead 7z.exe. (7za.exe l test.7z> output.txt, 7z.exe - doesn't work).

     
  • upscalevalley

    upscalevalley - 2022-12-29

    To output the list produced by 7-Zip to a file in command line mode, you can use the -scc option followed by the name of the character set to use for the output, and then redirect the output to a file using the > operator. Here is an example of how you can do this:
    7z l -sccUTF-8 archive.7z > list.txt
    This command will create a file called list.txt in the current directory, and it will contain the list of files in the archive.7z file, encoded in UTF-8 character set.
    You can also use the -scsUTF-8 option instead of -sccUTF-8, which will specify the character set to use for both the input and output.
    If you want to append the list to an existing file, rather than overwriting it, you can use the >> operator instead of >. For example.
    7z l -sccUTF-8 archive.7z >> list.txt
    This will add the list produced by 7-Zip to the end of the list.txt file, rather than overwriting it.
    I hope this helps!

     

Log in to post a comment.