batch script and wildcard (problem with *)

Advertisement

serfisar
Joined:
Posts:
3

batch script and wildcard (problem with *)

Hi!
Please, explain me this issue.
When I'm using this command from cmd (manually)
get *%x%.csv
where x = 2020_02_03
Everything working fine
But, when I use it in batch script, WinSCP copy all files from directory.

Reply with quote

Advertisement

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

Re: batch script and wildcard (problem with *)

It must be something about your batch file. As such, it's probably not a WinSCP problem, but if you post your batch file, we can take a look anyway.

Reply with quote

serfisar
Joined:
Posts:
3

Re: batch script and wildcard (problem with *)

set WinSCP="C:\winscp\winscp.exe"
 
cd C:\lftp-4.6.5.win64-openssl\bin
 
date.exe "+%Y-%m-%d" --date="1 day ago" > C:\Temp\tmp
 
set /p x= < C:\Temp\tmp
 
del C:\Temp\tmp
 
set protocol=ftp
set user=MY_USER
set password="MY_PASSWORD"
 
set host=SOMEHOST
 
%WinSCP%  %protocol%://%user%:%password%@%host% /command "lcd C:\recon\input" "get *%x%.csv" "exit"

Reply with quote

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

Re: batch script and wildcard (problem with *)

I do not see any problem. Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=C:\path\to\winscp.log command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Did you check the output of the batch file? How does the final WinSCP command-line look like?

Though are you aware, that you can implement this easily with WinSCP TIMESTAMP feature?
https://winscp.net/eng/docs/scripting#timestamp

... "get *%%TIMESTAMP-1D#yyyy-mm-dd%%.csv" ...

Reply with quote

Advertisement

You can post new topics in this forum