Re: Automate --> copy new file SFTP to local machine and copy file from local machine to different S
Thank you so much. I modified code, Its working now.
%TIMESTAMP%
syntax
get UVW_TNI_09_CHAR_E_MM_DD_YYYY.XML D:\Shares\SDF123.UVW.RFTI.%TIMESTAMP#yyyymmdd.hhnn%.01.bkp
UVW_TNI_09_CHAR_E_MM_DD_YYYY.xml (Source filename on sftp) --> SDF123.UVW.RFTI.YYYYMMDD.HHMM.01.bkp (renamed file name in local machine)
# Connect to SFTP server using password
open sftp://xyz:P@ssw0rd;fingerprint=ssa-xyz-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00@ftp.fg.com/usefor/fordownloadfiles/
# Download file
get UVW_TNI_09_CHAR_E_MM_DD_YYYY.XML D:\Shares\SDF123.UVW.RFTI.YYYYMMDD.HHMM.01.bkp
# Exit WinSCP
exit
set mytime=.0
if /I %time:~0,2% gtr 09 set mytime=%date:~10%_%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%
if /I %time:~0,2% lss 10 set mytime=%date:~10%_%date:~4,2%%date:~7,2%_0%time:~1,1%%time:~3,2%
COPY D:\Shares\SDF123.UVW.RFTI.YYYYMMDD.HHMM.01.bkp D:\Shares\SIDS\SDF123.UVW.RFTI.%mytime%.bkp
# Connect to SFTP server using a password
open sftp://FRANK:P@ssw0rd;fingerprint=FRA-UVW-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00@ftp.gg.com/useme/foruploadfiles/
# Upload file
put D:\Shares\SDF123.UVW.RFTI.YYYYMMDD.HH.01.bkp /useme/foruploadfiles/ -nopreservetime
exit
CALL D:\Shares\Hold\BatScr\GETfileandrename.bat (Covers 1 and 2 task)
timeout /t 30
CALL D:\Shares\Hold\BatScr\Copyfile.bat (covers task 3)
timeout /t 30
CALL D:\Shares\Hold\BatScr\PUTfile.bat