Home > Software design >  Downloading today's file from FTP server using WinSCP from batch file fails with "Mask is
Downloading today's file from FTP server using WinSCP from batch file fails with "Mask is

Time:01-22

I have a batch file that receives an argument then passes that argument to a text scrip file that invokes WinSCP to download a file.

My goal is to download today's file.

I am able to download the file if in the text script file I don't have >=today.

What do I need to change to download today's file, if it exists?

Batch File

set arg1=%1
set CurrentPath=C:\Temp\

rem drive
c:

rem folder do WinSCP
cd C:\Program Files (x86)\WinSCP

rem Download file
winscp.exe /console /script=%CurrentPath%sftp.txt /parameter %arg1%

Text script file

option batch abort
option confirm off 

# Connect
open <.....> 

# Download file to
get %1%>=today "C:\Temp\"

# Disconnect
close

The error I'm getting:

Mask is invalid near '=today'

enter image description here

CodePudding user response:

I do not think this is about passing parameters.

But the today keyword is a "recent" feature (WinSCP 5.14 from October 2018). So you probably have an old version of WinSCP that does not support it.


If you do not have a version of WinSCP that supports today, you can use %TIMESTAMP% pattern:

get %1%>=%TIMESTAMP#yyyy-mm-dd% "C:\Temp\"

Though you should always use the latest version of WinSCP, if you want to stay safe.

CodePudding user response:

Replace

As-Is

# Download file to
get %1%>=today "C:\Temp\"

To-Be

# Download file to
get -filemask= %1%"*>1D" "C:\Temp\"
  •  Tags:  
  • Related