onlyforbopi
7/25/2018 - 10:56 AM

WINSCP - Useful Scripts

getremotedirlist : get remote directory listing

::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: in ftp script : 

option batch on
option confirm off

OPEN  sftp://intf_ftp:deippc@10.11.18.110
CD    /Interfaces/Payments/AA/Incoming/unprocessed
LCD   C:\Users\p.doulgeridis\Desktop
option transfer ASCII

LS

close
exit

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: in .bat script -> call ftp script

winscp.com /script=C:\Users\p.doulgeridis\Desktop\remoteftpdirlisting\testdirftp >PANOSOUT.1.TXT

pause
@echo off



REM SET MAIL_PATH=C:\Users\p.doulgeridis\Desktop\BATCH_FOLDERCHECKS\
REM SET MAIL_NAME=MailFwteinis.py 
REM set REMOTE_PATH=/Interfaces/Thalis/Incoming/processed/Completed20190416_20190417_
REM winscp.com /command ^
    REM "open sftp://intf_ftp:deippc@10.11.18.110" ^
    REM "stat %REMOTE_PATH%*" ^
    REM "exit"







SET MAIL_PATH=C:\Users\p.doulgeridis\Desktop\BATCH_FOLDERCHECKS\
SET MAIL_NAME=MailFwteinis.py 
set REMOTE_PATH=/Interfaces/Thalis/Incoming/processed/Completed20190416_20190417_*
winscp.com /command ^
    "open sftp://intf_ftp:deippc@10.11.18.110" ^
    "option failonnomatch on" ^
    "ls %REMOTE_PATH%" ^
	"exit"
 
 
if %ERRORLEVEL% neq 0 goto error
 
echo File %REMOTE_PATH% exists
echo LAUNCHING MAIL
python %MAIL_PATH%%MAIL_NAME%
echo Mail Done
exit /b 0
 
:error
echo Error or file %REMOTE_PATH% not exists
exit /b 1