First scripts

Advertisement

Ian
Joined:
Posts:
1
Location:
UK

First scripts

Ok, apologies first I'm new to this. I am wanting to write a batch script to put multiple files onto a server, overwriting existing files, but am currently getting an error:

Are you sure you want to transfer multiple files to a single file 'BW' in a directory '/'?
The files will overwrite one another.
If you actually want to transfer all files to a directory '/BW/', keeping their name, make sure you terminate the path with a slash.
File or folder 'switch' does not exist.
System Error. Code: 2.
The system cannot find the file specified
(A)bort, (R)etry, (S)kip, Ski(p) all: Abort

My script is
:@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="D:\WinSCP\AgressoUATUpload.log" /ini=nul ^
  /command ^
    "open sftp://***:****@******/ -hostkey=""ssh-rsa 9999 *****^
    "put -nopreservetime switch C:\Stuff\Invoices\NightlyDBExport\FilesTST\*.txt "/AB File Import/UAT/"" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%

Any help gratefully appreciated

Reply with quote

Advertisement

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

Re: First scripts

What is the purpose of the "switch" in your put command? It looks like a mistake.

Other issue is that your quotes are wrong.
See https://winscp.net/eng/docs/commandline#syntax

So assuming the "switch" is a mistake, the command you wanted is probably this:
    "put -nopreservetime C:\Stuff\Invoices\NightlyDBExport\FilesTST\*.txt ""/AB File Import/UAT/""" ^

Reply with quote

Advertisement

You can post new topics in this forum