Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Guest

Re: WinSCP batch script is not is not downloading latest file

Replied
mar052y

WinSCP batch script is not is not downloading latest file

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 'path_to_files.'" ^
    "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%