Link to home
Start Free TrialLog in
Avatar of Tek Info
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.

@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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tek Info
Tek Info

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?
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.