7z.exe 允许附加,但 7zg.exe 声称文件已存在

7z.exe 允许附加,但 7zg.exe 声称文件已存在

这是一个奇怪的问题。我在 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

相关内容