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"
}
}
啊 - 是的,你是对的。非常感谢! –