- <#*,:&cls
- @echo off
- pushd "%~dp0"
- Powershell -NoProfile -ExecutionPolicy RemoteSigned -Command ". ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~0\" -ReadCount 0 | Out-String ))) "
- popd
- pause
- exit /b
- #>
- Add-Type -AssemblyName System.IO.Compression.FileSystem
- # 目录列表,绝对路径或相对路径
- Get-ChildItem -Path *.txt -Recurse | Foreach-Object {
- if (!$_.PSIsContainer) {
- $_.PSChildName
- }
- } -OutVariable txtlist | Out-Null
- Get-ChildItem -Path *.zip -Recurse | ForEach-Object {
- if (!$_.PSIsContainer) {
- try {
- $archive = [System.IO.Compression.ZipFile]::Open($_.FullName, 'Read')
- $archive.Entries | ForEach-Object {
- if ($_.Name -like '*.txt') {
- $_.Name
- }
- }
- } finally {
- $archive.Dispose()
- }
- }
- } -OutVariable +txtlist | Out-Null
- $txtlist | Group-Object -OutVariable groupinfos
- "`n文本文件数量: " + $groupinfos.Count
复制代码
|