02-05-2024, 06:12 PM
(This post was last modified: 02-05-2024, 06:20 PM by TerryRitchie.)
(02-05-2024, 03:21 PM)euklides Wrote: Well...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:
I'm looking for a way to list the files inside a zip file...
Than'ks for ideas.
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
)
)
)