0
在powershell中,我應該如何個別壓縮文件夾中的所有文件?例如,我在一個文件夾中有10個文件,這意味着我想要10個拉鍊。如何分別壓縮文件夾中的所有文件?
以下是我的代碼,但它只能壓縮一個文件。
Add-Type -Path "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IO.Compression.FileSystem.dll"
function ZipFiles($zipfilename, $sourcedir)
{
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,
$zipfilename, $compressionLevel, $false)
}
ZipFiles "zippath" "sourcepath"
做在一個循環? –
@ivan_pozdeev你介意顯示一些示例代碼嗎?我是新來的powershell – johndoe
@johndoe我的回答有幫助嗎?你需要更好的解釋我如何實現答案? – Nick