![7z.exe 允许附加,但 7zg.exe 声称文件已存在](https://linux22.com/image/1526716/7z.exe%20%E5%85%81%E8%AE%B8%E9%99%84%E5%8A%A0%EF%BC%8C%E4%BD%86%207zg.exe%20%E5%A3%B0%E7%A7%B0%E6%96%87%E4%BB%B6%E5%B7%B2%E5%AD%98%E5%9C%A8.png)
这是一个奇怪的问题。我在 Windows 10 上运行 7-zip [64] 版本 16.04。
我有以下 powershell 脚本。$zipper 程序设置为 7z.exe,脚本运行良好。
如果我将 $zipper 程序更改为 7zg.exe,那么在脚本中第二次运行它时会出现错误。它抱怨 Gl.7z 档案已经存在!
如您所见,我甚至尝试将第二个文件夹 (sherlock) 的命令从“a”更改为“u”(更新),但这没有帮助。(对于 7z.exe,我不必这样做)。
这是什么情况?为什么 7zg.exe 与 7z.exe 不同?
clear-host
Set-Location $PSScriptRoot # set current directory to location of script
[string]$zipper = "$($Env:ProgramFiles)\7-Zip\7z.exe"
[Array]$archive = "GL.7z"
[Array]$flags = "a","-t7z","-mx1","-mmt=on","-ms=on", "-r"
[Array]$skip = "-xr!.svn","-xr!.vs","-xr!bin","-xr!obj","-xr!Properties","-x!*.csproj","-x!*.user","-x!*.sln","-x!*.suo","-x!web.config","-x!web.*.config"
if (Test-Path $archive) {
Remove-Item $archive
}
$startDate = Get-Date
Write-Output "starting at: $startDate"
$ElapsedTime = [System.Diagnostics.Stopwatch]::StartNew()
Write-Output "Toby............................................................................................"
[Array]$in = "..\Toby"
[Array]$cmd = $flags + $archive + $in + $skip
& $zipper $cmd
Write-Output "Sherlock............................................................................................"
[Array]$flags = "u","-t7z","-mx1","-mmt=on","-ms=on", "-r"
[Array]$in = "..\Sherlock"
[Array]$cmd = $flags + $archive + $in + $skip
& $zipper $cmd
exit
Write-Output "Watson............................................................................................"
[Array]$in = "..\Watson"
[Array]$wskip = "-xr!.svn","-xr!.svn", "-xr!obj", "-x!*.md", "-x!watson.log*.json", "-x!*.sln", "-x!*.suo", "-x!*.njsproj", "-x!*.dat", "-x!*.md", "-x!*LICENSE*", "-x!*.yml", "-x!*.git*", "-x!.npm*", "-x!*.c", "-x!*.txt", "-x!Makefile", "-x!.jshint*", "-x!readme*"
[Array]$cmd = $flags + $archive + $in + $wskip
& $zipper $cmd
Write-Output "Doc............................................................................................"
[Array]$in = "..\doc"
[Array]$cmd = $flags + $archive + $in + $skip
& $zipper $cmd
Write-Output "Setup............................................................................................"
[Array]$in = "..\setup"
[Array]$cmd = $flags + $archive + $in + $skip
& $zipper $cmd
exit
Write-Output "Base Maps Files............................................................................................"
[Array]$in = "..\BaseMaps"
[Array]$cmd = $flags + $archive + $in + $skip
& $zipper $cmd
write-host "Total Elapsed Time: $($ElapsedTime.Elapsed.ToString())"
# list files:
# &$zipper l $archive
# 7z e archive.zip -oc:\soft *.cpp -r