1
我們有一個腳本,它已成功將文件夾壓縮到7z,然後在壓縮後刪除該文件夾。 我們想要做的是將壓縮的7z文件移動到更便宜的存儲上的另一個位置,也用於備份/非現場歸檔目的。移動項目「路徑不受支持」。
我試過下面的,但是我收到一條錯誤消息「路徑不支持。」
有人能幫忙嗎?
Get-ChildItem 'E:\AbleyTest\TestFolder\_Archived\*' | Where-Object {
$_.PSIsContainer
} | Select-Object -Expand FullName | ForEach-Object {
& 7z.exe a -mx=9 -t7z "$_.7z" "$_"
if ($LastExitCode -eq 0) {
$folder = (Get-Item $_).Parent.Parent.Name
if (Test-Path "e:\archived\$folder") {
Move-Item -Path "$_.7z" -Destination "e:\archived\$folder\$_.7z"
} else {
New-Item "e:\archived\$folder" -Type directory
Move-Item -Path "$_.7z" -Destination "e:\archived\$folder\$_.7z"
}
Remove-Item -Path $_ -Force -Recurse
} else {
Add-Content "e:\scripts\archivelog $(get-date -f dd-MM-yyyy).txt" "$_ ran into error $LastExitCode while archiving"
}
}
啊 - 是的,你是對的。非常感謝! –