filemask script help needed please

Advertisement

jimboh
Joined:
Posts:
2
Location:
UK

filemask script help needed please

Hi,

I've sat and read the documentation for the last few hours and tried many combinations, but cannot figure out the syntax for what I'm trying to achieve. All I want is to connect to the remote directory and use a filemask to grab only the .txt files that were modified/created since midnight last night (we have around 90 files arriving each morning).
Looking at the docs, where it mentions being able to use '>yesterday' or '>0DS' makes me think it's simple, but none of these work in my batch file:
"get -filemask=*>yesterday *.TXT" ^
"get -filemask=*>0DS *.TXT" ^
"get -filemask=>1DS *.TXT" ^

I have no idea what I'm doing wrong.
The Transfer Settings Dialog is even more confusing. If I try adding:
>yesterday or >0DS in the filemask box, it refuses to allow it. Yet the docs say you can use >yesterday or >0DS as a filemask.

Please help before I have a nervous breakdown :)

Thank you!

Reply with quote

Advertisement

jimboh
Joined:
Posts:
2
Location:
UK

Hi,

Thank you for the reply.

I replaced the line I had with what you suggested and am getting the error "Missing parameter for command 'get'."
Here's the script I'm trying to use:
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log=""D:\XXXXX\WinSCP.log"" /ini=nul ^
  /command ^
    "open sftp://username:password@XXX.XXX.XXX.XXX/ -hostkey=""ssh-rsa 2048 XXXXXXXXXXX""" ^
    "cd /XXXX/XXXX/" ^
    "lcd D:\XXXX" ^
   "get -filemask=*.txt>1DS" ^
   rem "get -filemask=*.txt>yesterday" ^ 
    "exit"
I have tried with the line rem'd out too and got the same error. This all works if I replace the get line with:
"get *30082019*.txt" (or any other date)
I cannot figure out what parameter I'm missing.
Thanks again :)

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

You still have to specify the source argument for the get command.
You can use *:
get -filemask=*.txt>yesterday *
Or in this simple case, you do not need to use -filemask switch at all:
get *.txt>yesterday
See https://winscp.net/eng/docs/scriptcommand_get

Though your attempt *30082019*.txt makes me curios what you actually want. Do you want to select files by their modification timestamp? That's what >yesterday does. Or by a timestamps contained in their filenames? What *30082019*.txt does.

Reply with quote

Advertisement

You can post new topics in this forum