E=mc2
asked on
Modify FTP script
I would like to modify this FTP script below so that it does the following
1. Download any new files to the local directory. (So the script needs to determine what it downloaded last time, so that it doesn't download it again, unless it it's easier to write the script so as to download everything it sees in the remote directory to the local directory and just overwrite any files which it sees, which is ok as well, in this scenario).
2. Does not delete the previous files from the remote directory.
1. Download any new files to the local directory. (So the script needs to determine what it downloaded last time, so that it doesn't download it again, unless it it's easier to write the script so as to download everything it sees in the remote directory to the local directory and just overwrite any files which it sees, which is ok as well, in this scenario).
2. Does not delete the previous files from the remote directory.
@echo off
setlocal
set password=xxxxxxxxxx
set /p password=<%~nx0:password
if not "%password%"=="" goto OK
set /p password=Enter password:
echo %password%>%~nx0:password
:OK
set localdir=\\server1\main\
set remotedir=/out
set ftpserver=xxxxx.xxxxxxxxxxx.com
set username=xxxxxxxx
::del "%localdir%\*.*" /q
call :GetFtpFiles
call :ClearFTPFiles
exit /b
:GetFTPFiles
(echo open %ftpserver%
echo user %username% %password%
echo bin
echo cd %remotedir%
echo lcd "%localdir%"
echo mget *.*
echo quit
) | ftp -n -i
exit /b
:ClearfTPFiles
(echo open %ftpserver%
echo user %username% %password%
echo cd %remotedir%
(for /f "tokens=*" %%a in ('dir /b /a-d "%localdir%\*.*"') do @echo dele "%%~a")
echo quit
) | ftp -n -i -d
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to all, let me take a look.. and try the script..
This depends on the FTP server. Some provide this info. Some don't.
Then check all times against your local copy of files.
Or... you can just use rsync, which already does all this work for you.