Search code examples
batch-fileftpcommand-line-argumentswinscp

Downloading today's file from FTP server using WinSCP from batch file fails with "Mask is invalid near '=today'"


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


Solution

  • Replace

    As-Is

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

    To-Be

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