PowerShell 压缩子文件夹


$SourcePath = "D:\Reports\DeskReports\2016Q2"
$ArchivePath = "D:\Reports\DeskReports\Archive_2016Q2"
$7ZipPath = "D:\data\7-Zip\7z.exe"

Get-ChildItem -Path $SourcePath -Recurse | Where-Object {$_.PSIsContainer} | ForEach-Object {
$directoryFullName = $_.FullName
$directoryName = $_.Name
Invoke-Expression -Command "$7ZipPath a $ArchivePath\$directoryName.zip $directoryFullName\*"
}

 

posted @ 2017-02-20 20:37  BI-Info  阅读(738)  评论(0编辑  收藏  举报