我試圖壓縮一個文件夾,但使用powershell排除多個目錄。7zip - powershell排除變量的文件/文件夾
我有以下幾點:
if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe")) {throw "$env:ProgramFiles\7-Zip\7z.exe needed"}
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
$Source = "D:\Zip\*"
$Target = "D:\backup.7z"
$exclude = 'Customer\Images\*'
sz a -xr!'$Customer\Images\*' $Target $Source
這工作得很好。但是,當我想改變的-xr!
到-xr!'$exclude'
或-xr!$exclude
它停止工作由於某種原因。上面分配的變量是否被解析?
變量未在單引號字符串中擴展。 – wOxxOm
它不能在'-xr!$ exclude'中使用.. –