I have a windows batch job running that calls WINSCP to connect and upload the file to the FTP site. However the file being uploaded is user generated and complied. So if a scenario happens where the user forgets to create the file and places it in the appropriate folder the script will just assume no files found, and close session. Is there a way to create a IF GOTO or IF ELSE on that condition?
Sample of my code.
Main Batch Job
set path = C:\SOMEWHERE
C:\SOMEWHERE\WinSCP.com /script=C:\SOMEWHERE\WINSCPFTPSITE1.txt > C:\SOMEWHERE\LOGS\UPLOADLOG.txt 2>&1 2>&1
if %ERRORLEVEL% neq 0 goto error
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& 'C:\SOMEWHERE\SendMailSuccess.ps1'"
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& 'C:\SOMEWHERE\SendMailFailure.ps1'"
echo Starting transfer from UPLOAD to archive...
xcopy C:\SOMEWHERE\UPLOAD\*.* C:\SOMEWHERE\UPLOAD\ARCHIVE /S /E >> C:\SOMEWHERE\LOGS\UPLOADLOG.txt 2>&1 2>&1
del C:\SOMEWHERE\UPLOAD\*.* /Q /F >> C:\SOMEWHERE\LOGS\UPLOADLOG.txt 2>&1
echo Task Completed.
Than the script that runs for WINSCP
option batch abort
option confirm off
open sftp://tinkerbell:firstname.lastname@example.org/ -hostkey="ssh-rsa 7777 lalalalallalalalalalallalalalallalalalalalallalalalalla"
So when the user forgets to place in the file, the batch job continues but since there is no error it just continues its merry way. I am new to batch scripting and learning for the first time with this assignment. Is there a way to target that condition or result so I can do a IF GOTO or IF ELSE within the batch script or within the WINSCP script?