WINSCP批处理不是不是下载最新文件

发布于 2025-01-30 05:43:49 字数 819 浏览 1 评论 0原文

我正在使用“ -latest”开关,但它仅下载最旧的文件,而不是最新的“最新”。文件文件按上升顺序,新文件/生成为+1,请参见下面的示例。

文件 G3160V00 G3161V00 G3162V00 G3163V00 G3164V00

当前我运行脚本时,它下载了最古老的“ G3160V00”,我期望最新的“ G3164V00”不确定是否可以根据文件名下载。

当前脚本:

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\FTPtemp\FTPtesting\WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://user:password@sc01/ -rawsettings ProxyPort=0" ^
    "cd 'KINP.EDI.BI04801.'" ^
    "lcd C:\FTPtemp\FTPtesting" ^
    "get -latest *" ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
exit /b %WINSCP_RESULT%

这是移至WINSCP之前使用的脚本,该脚本仅下载最新文件。

@ftp -s:"%~f0"&GOTO:EOF
open sc01
user
password
lcd C:\FTPtemp\FTPtesting
prompt
cd ..
cd KINP.EDI.
mget BI04801(0)
bye

I'm using the "-latest" switch but it's only downloading the oldest file rather then latest "newest". Files file are in ascending order, ever new file/generation is +1 see sample below.

Files
G3160V00
G3161V00
G3162V00
G3163V00
G3164V00

Currently when I run the script it downloads the oldest "G3160V00", where I'm expecting the latest "G3164V00" not sure if it possible to download based on filename.

Current script:

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\FTPtemp\FTPtesting\WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://user:password@sc01/ -rawsettings ProxyPort=0" ^
    "cd 'KINP.EDI.BI04801.'" ^
    "lcd C:\FTPtemp\FTPtesting" ^
    "get -latest *" ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
exit /b %WINSCP_RESULT%

This is the script used before moving over to WinSCP, this one would download only the latest file.

@ftp -s:"%~f0"&GOTO:EOF
open sc01
user
password
lcd C:\FTPtemp\FTPtesting
prompt
cd ..
cd KINP.EDI.
mget BI04801(0)
bye

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文