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

Tony__

I think I figured it out. I missed the point that the scrip should be in a separate file and MOVE in a bat file.
Now I just need to figure out how to append messages (either successful or unsuccessful) to a log file.
Appreciate your help,
-Tony.
martin

Re: Checking result of the script and moving local files

winscp.com /script=example.txt
if %ERRORLEVEL% neq 0 goto error
 
echo Upload succeeded, moving local files
move *.* c:\backup\
exit 0
 
:error
echo Upload failed, keeping local files
exit 1

The above code is a Windows batch file (.bat), that first runs WinSCP to upload the files and than moves the uploaded files away (using Windows shell commands).
Tony_

Checking result of the script and moving local files

Hello,

I need to do the following:

1. Move all the files that fall under certain pattern (in this case all csv files that start with GL_.... GL_*.csv) from local machine to a remote SFTP server;
2. Check if the move was successful;
3. If it was, move all the local files to another directory

I got the 1st part working somewhat. I created a batch file and am able to run it from the command line. It moves the files from the local machine to the remote SFTP server just fine (I still need to figure out how to automate this process...probably via Windows scheduler).
I'm not sure how to check for the successful script execution and based on that build a logic to move the local files to another directory.

I saw an example here: https://winscp.net/eng/docs/guide_automation#results but I cannot figure out where all of that stuff belongs to. I need to make it part of the same batch file I'm executing from the command line.

Furthermore, it sounds like I cannot really move local files to another location using batch scripting? I found an example here: https://winscp.net/eng/docs/script_local_move_after_successful_upload but again, I'm not sure where to add this stuff after executing batch file:
if %ERRORLEVEL% neq 0 goto error
 
echo Upload succeeded, moving local files
move *.* c:\backup\
exit 0
 
:error
echo Upload failed, keeping local files
exit 1


TIA,
-Tony.