list - Powershell脚本列出目录中的Zip文件及其大小

标签 list powershell directory zip size

我遇到了一种在目录中列出Zip内容的方法-我想包括文件大小信息。

[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
foreach($sourceFile in (Get-ChildItem -filter '*.zip'))
{
    [IO.Compression.ZipFile]::OpenRead($sourceFile.FullName).Entries.FullName |
            %{ "$sourcefile`:$_" }
}

有人可以帮我添加尺寸信息吗?当前显示格式为:
zipName:zipContentName

我想保持格式为:
zipName:zipContentName:zipContentSize

最佳答案

而不是遍历全名,而是遍历entries本身:

[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
foreach($sourceFile in (Get-ChildItem -filter '*.zip'))
{
    [IO.Compression.ZipFile]::OpenRead($sourceFile.FullName).Entries |
            %{ "$sourcefile`:$($_.FullName):$($_.Length)";  }
}

关于list - Powershell脚本列出目录中的Zip文件及其大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30374258/

相关文章:

java - 当日历selenium java上出现2个日期时,如何选择可点击的日期?

list - Prolog 中的简单平方程序

powershell - 不使用-Recurse将文件从一个文件夹移动到另一个文件夹

c# - 删除所有没有特定扩展名文件的文件夹和子目录

java - 从列表中删除重复组合

python - 存储 2D 数据的最佳方式是什么

powershell - 使用 set-acl 和 powershell 设置继承和传播标志

json - 来自 JSON 文件的 Powershell Out-GridView

Java - 获取当前 JAR 中的文件名列表

php - 如何存储敏感文件并只允许某些用户访问