You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

FileZilla Pro CLI在PowerShell执行put时无法取消文件存在提示的问题

FileZilla Pro CLI 取消上传确认提示问题解决

原脚本的核心错误

  1. option命令格式错误:你用了option cli.prompt.file_exists:6,但FileZilla Pro CLI的option命令语法是用空格分隔参数名和值,而非冒号,正确写法是option cli.prompt.file_exists 6。这个错误会导致全局取消确认的设置根本不生效。
  2. 无效命令nput:FileZilla Pro CLI中没有nput命令,这是拼写错误,应该使用标准的put命令。
  3. -e参数格式错误:你尝试的-e:size_newer格式不对,正确的参数写法是-e size_newer(空格分隔选项和条件)。

修正后的完整脚本

$scriptContent = @"
option cli.prompt.file_exists 6
open sftp://${ftpUser}:${ftpPass}@${ftpHost}:22
lcd $localDirectory
"@

Get-ChildItem -Path $localDirectory -Recurse | ForEach-Object {
    if ($_.PSIsContainer) {
        $relativePath = $_.FullName.Substring($localDirectory.Length) -replace "\\", "/"
        $remoteDirPath = "./$relativePath"
        $scriptContent += "mkdir $remoteDirPath`n"
    } else {
        $localFile = $_.FullName -replace "\\", "/"
        $relativePath = $_.DirectoryName.Substring($localDirectory.Length) -replace "\\", "/"
        $remoteFilePath = if ($relativePath) { "./$relativePath/$($_.Name)" } else { "./$($_.Name)" }
        
        # 按需选择:仅上传更新/大小不同的文件
        $scriptContent += "put -e size_newer `"$localFile`" `"$remoteFilePath`"`n"
        # 若不需要条件,直接使用put(依赖全局option设置自动覆盖)
        # $scriptContent += "put `"$localFile`" `"$remoteFilePath`"`n"
    }
}

额外注意事项

  • 将option命令移至open之前,确保连接SFTP服务器前就加载全局设置,避免设置不生效。
  • 若仍有确认提示,可在put命令后追加-n参数(如put -n ...),强制跳过单个文件的确认提示,和全局option设置配合使用更稳妥。
  • 确认你的FileZilla Pro CLI版本为最新,旧版本可能存在参数兼容性问题。

内容的提问来源于stack exchange,提问作者DarkW1nter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 12:10:10