8,330 questions
Maybe not the most elegant way, but it should give you what you asked for:
$ZipRoot = 'C:\ZipFolder\*'
Add-Type -AssemblyName System.IO.Compression.FileSystem
Get-ChildItem -Path $ZipRoot -Filter *.zip -Recurse -File |
ForEach-Object{
$PDFCount = ([IO.Compression.ZipFile]::OpenRead($_.FullName).Entries|
Where-Object{$_.Name -like "*.pdf"}).Count
[pscustomobject]@{ # no need for the file name if you only want the number of files by directory
DirectoryName = $_.directoryname
PDFCount = $PDFCount
}
} |
Group-Object -Property DirectoryName|
ForEach-Object{
$Tot = 0
$DirectoryName = $_.Name
$_.Group |
ForEach-Object{
$Tot += $_.PDFCount
}
[PSCustomObject]@{ # ignore the original, this one's a summary
DirectoryName = $DirectoryName
PDFCount = $Tot
}
}