按照技术食谱的示例,我设法列出了 ZIP 文件的内容(使用 7-Zip:
FOR /F "tokens=* delims=" %%A in ('dir /b /s *.zip') do (7z.exe l -r "%%A" >> listing.txt)
但是,这只是将 ZIP 文件的整个目录结构转储到一个文本文件(称为 list.txt)中。
我只想列出最高级别目录的目录名称,例如
Example.Zip
7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Listing archive: C:\Users\Test\Desktop\7zip\Demo.zip
--
Path = C:\Users\Test\Desktop\7zip\Demo.zip
Type = zip
Physical Size = 1252
Date Time Attr Size Compressed Name
------------------- ----- ------------ ------------ ------------------------
2013-04-24 13:12:26 D.... 0 0 Directory Three\Sub Folder One
2013-04-24 13:13:00 D.... 0 0 Directory Three\Sub Folder Three
2013-04-24 13:12:54 D.... 0 0 Directory Three\Sub Folder Two
2013-04-24 13:12:26 D.... 0 0 Directory Two\Sub Folder One
2013-04-24 13:13:00 D.... 0 0 Directory Two\Sub Folder Three
2013-04-24 13:12:54 D.... 0 0 Directory Two\Sub Folder Two
2013-04-24 13:12:26 D.... 0 0 Directory One\Sub Folder One
2013-04-24 13:13:00 D.... 0 0 Directory One\Sub Folder Three
2013-04-24 13:12:54 D.... 0 0 Directory One\Sub Folder Two
------------------- ----- ------------ ------------ ------------------------
0 0 0 files, 9 folders
我只希望文本文件包含:
- 目录一
- 目录二
- 目录三
谁能建议我如何实现这一目标?