Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

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/""" ^
Ian

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