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

DaMatt

Thank you, works like a charm!
Can you give me a hint how I start an other .cmd file if the result ist success (move and rename).

Thanks
martin

Re: Upload in batch shouldn't overwrite file on server

If you want the script to upload only files that do not exist yet in the remote folder (in any version, any size, any timestamp) on the server, use:
synchronize remote -filemask=Test.txt -criteria=none

See https://winscp.net/eng/docs/scriptcommand_synchronize
DaMatt

Upload in batch shouldn't overwrite file on server

Hello to the forum.

I have (II think) a quite simple task to perform but I'm stuck.

  1. I want to transfer via batch and task a textfile with time-bookings to a server, where they are processed by a task and then the file will be removed from the server. Therefore my upload batch should not overwrite the file on the server until the file is processed and removed from the server.
  2. (not startet because of 1.) When successful transferred, the file should be locally moved to an oder folder and renamed.

I created a script out of the GUI but the batch keeps overwriting the existing file on the server. I tried option batch on, option batch abort, in Preferences "No confirmations for background transfers" is not activated. Please help! Thx

Script:
@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Zeiterfassungfiles\FTP_Log\WinSCP_Test.log" /ini=nul ^
  /command ^
    "option batch abort" ^
    "open sftp://xxx" ^
    "lcd C:\Zeiterfassungfiles" ^
    "cd /sftp/ZEIT" ^
    "put Test.txt" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%