Reputation: 17
I have came across a way to list Zip content in a Directory - I would like to include the file size information.
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
foreach($sourceFile in (Get-ChildItem -filter '*.zip'))
{
[IO.Compression.ZipFile]::OpenRead($sourceFile.FullName).Entries.FullName |
%{ "$sourcefile`:$_" }
}
Could someone help me to add size information - current display format is:
zipName:zipContentName
I would like to keep formatting as:
zipName:zipContentName:zipContentSize
Upvotes: 1
Views: 2991
Reputation: 11222
Rather than looping through the FullNames, loop through the entries themselves:
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')
foreach($sourceFile in (Get-ChildItem -filter '*.zip'))
{
[IO.Compression.ZipFile]::OpenRead($sourceFile.FullName).Entries |
%{ "$sourcefile`:$($_.FullName):$($_.Length)"; }
}
Upvotes: 3