Can I use a variable to repeat a get -filemask destination path

Advertisement

rustlerush
Joined:
Posts:
1
Location:
England

Can I use a variable to repeat a get -filemask destination path

I have
get -filemask fileA*.txt>today \\192.168.1.10\fixeddestination\
get -filemask fileB*.txt>today \\192.168.1.10\fixeddestination\
get -filemask fileC*.txt>today \\192.168.1.10\fixeddestination\
Does a way exist to declare the path \\192.168.1.10\fixeddestination\ just once as in:-
var destination = \\192.168.1.10\fixeddestination\
enabling me to write
get -filemask fileA*.txt>today destination\

Reply with quote E-mail

Advertisement

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

Re: Can I use a variable to repeat a get -filemask destination path

You can set an environment variable in the parent batch file:
set DESTINATION=\\192.168.1.10\fixeddestination\
and use it in WinSCP script like:
get fileA*.txt>today %DESTINATION%
See https://winscp.net/eng/docs/scripting#variables
(Note that in your script the empty -filemask is redundant)

Another option is:
Upload to multiple servers / Parametrized script

Or you can just change the remote working directory:
cd \\192.168.1.10\fixeddestination\
get fileA*.txt>today
get fileB*.txt>today
get fileC*.txt>today

Or specify the multiple sources in one command:
get fileA*.txt>today fileB*.txt>today fileC*.txt>today \\192.168.1.10\fixeddestination\

Or even simplify the mask using set pattern to:
get file[ABC]*.txt>today \\192.168.1.10\fixeddestination\
https://winscp.net/eng/docs/file_mask#basic

Reply with quote

Advertisement

You can post new topics in this forum