這是我目前使用的代碼:我該如何更新此代碼才能第二次運行,但只能在已解壓縮的zip壓縮文件中運行?
# Don't include "\" at the end of $NewSource - it will stop the script from
# matching first-level subfolders
$ignore = "somename"
$files = gci $NewSource -recurse | Where {
$_.Extension -match "zip||prd" -and $_.FullName -notlike $ignore
}
foreach ($file in $files) {
$NewSource = $file.FullName
# Join-Path is a standard Powershell cmdLet
$destination = Join-Path (Split-Path -Parent $file.FullName) $file.BaseName
Write-Host -Fore green $destination
$destination = "-o" + $destination
# Start-Process needs the path to the exe and then the arguments passed
# separately. You can also add -wait to have the process complete before
# moving to the next
Start-Process -FilePath "C:\Program Files\7-Zip\7z.exe" -ArgumentList "x -y $NewSource $destination" -Wait
}
但是,一旦它完成我需要通過新的目錄回去,只解壓縮.zip文件解壓縮後所創建的我.prd文件。在這裏需要一些幫助,因爲我的嘗試不起作用,並且當前解壓並覆蓋所有以前解壓縮的.prd和.zip文件。
這個答案,雖然它改善了我所有的代碼沒有回答我發佈的問題。 – Underdog
@Underdog現在確實如此。 –