Upload in batch shouldn't overwrite file on server

Advertisement

DaMatt
Joined:
Posts:
2
Location:
Austria

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%

Reply with quote

Advertisement

DaMatt
Joined:
Posts:
2
Location:
Austria

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

Reply with quote

Advertisement

You can post new topics in this forum