我根据tech-recipes的示例成功地列出了ZIP文件的内容(使用7-Zip):
FOR /F "tokens=* delims=" %%A in ('dir /b /s *.zip') do (7z.exe l -r "%%A" >> listing.txt)
然而,这只是将ZIP文件的整个目录结构转储到一个名为“listing.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
我只想让文本文件包含以下内容:
- 目录一 - 目录二 - 目录三
有人能提供如何实现这个目标的建议吗?