清单的ZIP文件的内容 [英] Listing the contents of a ZIP file

查看:214
本文介绍了清单的ZIP文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下我已成功地列出一个ZIP文件的内容技术含量的配方的例子(使用的7-Zip:

Following an example of tech-recipes I have managed to list the contents of a ZIP file (using 7-Zip:

FOR /F "tokens=* delims=" %%A in ('dir /b /s *.zip') do (7z.exe l -r "%%A" >> listing.txt)

不过,这只是转储出来的ZIP文件的整个目录结构到一个文本文件(称为listing.txt)。

However, this just dumps out the entire directory structure of the ZIP file into a text file (called listing.txt).

我只想列出的最高级别目录的目录名称例如

I only want to list the directory names of the highest level directories e.g.

Example.Zip

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

我只希望该文本文件包含:

I would only want the text file to contain:


  • 目录中的一个

  • 目录中两个

  • 目录中有三个

任何人都可以建议我怎么能做到这一点?

Can anyone suggest how I could achieve this?

推荐答案

7Z似乎并不为这个内置的关键,但是你可以做一些批处理脚本(在文件名和显示线斜线这个搜索如果斜线未找到):

7z doesn't seem to have builtin key for this, however you can do some batch scripting (this one searches for slash in file name and displays line if slash not found) :

7z.exe l -r archive.zip > lines.txt

@echo off

setlocal ENABLEDELAYEDEXPANSION

for /f "tokens=*" %%a in (lines.txt) do (
  set line=%%a
  set srch=!line:\=!
  if "!line!" == "!srch!" (
     echo !line!
  )
)

这篇关于清单的ZIP文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆