Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making the content list of files inside a Zip ?
#3
(02-05-2024, 03:21 PM)euklides Wrote: Well...
I'm looking for a way to list the files inside a zip file...

Than'ks for ideas.
I was playing around with 7Zip ( 7z.exe ) to see if I could get the results you want. The best I could get was this:

7z l -ba filename.zip

which lists output like this:

2014-08-21 00:37:55 ....A    1078326        45840    filename.ext
2014-08-22 10:19:59 ....A        13733                      anotherfile.txt
...
... etc..
...

You would need to parse out the information using code with this method of putting the listing into a file like so:

7z l -ba filename.zip > filelist.txt

However, I also found a batch file that strips everything except the file names themselves here:

https://stackoverflow.com/questions/5535...-filenames

A full explanation of how the batch file works is included in the link above. Read the entire posting as others posted alternative methods using powershell scripts as well. Pick the one you like best.

Code: (Select All)
@Echo Off
  REM Sending the output of 7z into a file to use later
  7z.exe l -slt "SomeFileIZipped.zip" >"ZipListRAW.txt"
 
  REM Example of 7z.exe command with '-ba' switch
  REM 7z.exe l -ba -slt "SomeFileIZipped.zip"
 
  REM If you do not use '-ba' in the 7z command above, you can simply skip the first
  REM 11-12 lines of the file to get ONLY the filenames (skips past first line containing
  REM "Path" which contains the original archive filename.
 
  For /f "Usebackq Skip=11 Tokens=1,3* Delims= " %%a in ("ZipListRAW.txt") do (
    REM Checking if %%a equals word "Path"
    If "%%a"=="Path" (
      If [%%c]==[] (
        Echo %%b
      ) ELSE (
        Echo %%b %%c
      )
    )
  )
.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
RE: Making the content list of files inside a Zip ? - by TerryRitchie - 02-05-2024, 06:12 PM



Users browsing this thread: 1 Guest(s)