Tek Info
asked on
Change this script batch script to synchronize remote directory to local directory
I would like to change this script so that it synchronizes files from the remote directory to the local directory.
No files must be deleted on the remote site, but if files do not exist on the remote site they can be deleted on the local folder.
No files must be deleted on the remote site, but if files do not exist on the remote site they can be deleted on the local folder.
@ECHO ON
:SetFileLogVariables SET localdir=C:\dev\site123 SET remotedir="dev\site123" SET logfile=C:\logs\FTP_dev_site123_sync.log
:SetPrgVariables SET prgwinscp="C:\Program Files\WinSCP3\WinSCP.com" SET winscplogin="DevSiteSync" SET winscpfile=%temp%\~tmpWinSCPFTPSyncT_%~N0.txt IF EXIST "%winscpfile%" DEL /Q /F "%winscpfile%"
:SetWinSCPSyncCommand SET ftpcmd=synchronize remote "%localdir%\"
:ftpout ECHO. >> %logfile% ECHO *************************** FTP OUT *************************** >> %logfile% ECHO Synchronizing files to %winscplogin% server on %date% at %time% >> %logfile%
ECHO option batch on >> %winscpfile% ECHO option confirm off >> %winscpfile% ECHO option transfer binary >> %winscpfile% ECHO open %winscplogin% >> %winscpfile% ECHO cd %remotedir% >> %winscpfile% ECHO %ftpcmd% >> %winscpfile% ECHO close >> %winscpfile% ECHO exit >> %winscpfile%
ECHO %winscpfile% >> %logfile% TYPE %winscpfile% >> %logfile% ECHO ------------------------------------------- >> %logfile% %prgwinscp% /script=%winscpfile% >> %logfile% ECHO ------------------------------------------- >> %logfile% IF EXIST "%winscpfile%" DEL /Q /F "%winscpfile%" ECHO Transmission complete on %date% at %time% >> %logfile% EXIT
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://www.experts-exchange.com/questions/29190612/Which-FTP-clients-will-allow-you-to-preserve-the-time-stamp-of-the-files-from-the-remote-ftp-folder.html - refer to my rsync comment.
ASKER
Thanks oBdA, however I don't seem to have a path at:
SET prgwinscp=C:\Program Files\WinSCP3\WinSCP.com ?
Is this where WinSCP should be installed?
SET prgwinscp=C:\Program Files\WinSCP3\WinSCP.com ?
Is this where WinSCP should be installed?
Well, you can install it into any directory you want (don't know what the 3 in that path is doing there, but I kept it from the original source).
Just change that variable to point to the path where you ended up installing WinSCP.
Just change that variable to point to the path where you ended up installing WinSCP.