我使用的是7z版本18.05,我只想列出存档内容的文件名。
如果我使用命令7z l myArchive.7z
我得到这个输出:
7-Zip 18.05 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-04-30
Scanning the drive for archives:
1 file, 146863932 bytes (141 MiB)
Listing archive: myArchive.7z
--
Path = myArchive.7z
Type = 7z
Physical Size = 146863932
Headers Size = 393
Method = LZMA:26
Solid = +
Blocks = 1
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2017-12-06 08:55:47 D...A 0 0 myArchive
2017-12-06 08:55:42 D...A 0 0 myArchive\folder
2017-12-05 19:50:41 ....A 21816530 146863539 myArchive\folder\Test.dat
2017-12-06 08:55:42 ....A 21877463 myArchive\folder\Test2.dat
2017-12-05 19:51:05 ....A 153953 myArchive\folder\Test3.dat
2017-12-05 19:50:41 ....A 4193 myArchive\folder\Test4.dat
2017-12-06 08:55:47 ....A 24128956 myArchive\log.txt
2017-12-06 08:55:47 ....A 79980 myArchive\readme.txt
2017-12-05 19:51:05 ....A 3256759999 myArchive\folder\zTest.txt
------------------- ----- ------------ ------------ ------------------------
2017-12-06 08:55:47 3324821074 146863539 7 files, 2 folders
我不知道为什么7z没有开关只列出文件名。如何只获得“名称”列?任何使用dos命令的建议?
如果您可以在计算机上安装PowerShell模块,则列出文件名很简单。这可以在任何现代支持的Windows系统上完成。
https://www.powershellgallery.com/packages/7Zip4Powershell/1.9.0描述了如何安装模块。
这是一个.bat文件脚本,显示其用法和输出。
C:>TYPE zipfnlist.bat
@ECHO OFF
SET "ZIP_FILENAME=.\7zIntf20.zip"
powershell -NoLogo -NoProfile -Command (Get-7Zip -ArchiveFileName "%ZIP_FILENAME%").FileName
C:>CALL zipfnlist.bat
bin
Properties
Ole32.cs
Program.cs
SevenZipFormat.cs
SevenZipInterface.cs
SevenZip.csproj
SevenZip.sln
bin\Debug
bin\Release
bin\Release\SevenZip.exe
Properties\AssemblyInfo.cs