Only Download Fully Uplaoded files from FTP
Posted: 10 Feb 2010 10:54
Hi Everyone,
I am trying to automate a batch file to constantly check an FTP site and download uploaded files and delete after the upload.
I have the batch file set up to upload the files to another ftp server when there is a succesfull download, log the entire process and rename/move the log file when complete
The problem i am having is that the batch file will download and delete the files mid-upload leaving me with nothing on the server and nothing locally.
what is the best way to set up the batch file to not download the files unless the person uploading is finished uploading?
Here is what i have so far:
@echo off
:LOOPY
echo username> ftpcmd.dat
echo password>> ftpcmd.dat
echo cd foldername>> ftpcmd.dat
echo mget *.*>> ftpcmd.dat
echo mdelete *.*>> ftpcmd.dat
echo bye>> ftpcmd.dat
echo username> ftpcmd1.dat
echo password>> ftpcmd1.dat
echo cd foldername>> ftpcmd1.dat
echo mput *exc*.*>> ftpcmd1.dat
echo quit>> ftpcmd1.dat
ftp -i -n -s:ftpcmd.dat 192.168.1.1 > ftp.log
find "bytes" ftp.log
set error=%errorlevel%
if not %error%==0 goto end2
ftp -i -n -s:ftpcmd1.dat 192.168.0.1 > ftp2.log
ren ftp.log FTPLOG%_%%date:~4,2%%-%%date:~7,2%%-%%date:~10%%.log
move FTPLOG*.log c:\Logs
:end2
del ftpcmd.dat
del ftpcmd1.dat
goto LOOPY --- i want to script to constantly run and not leave files on the ftp sever for long
Any help will be greatly appreciated
Thanks!
Elliot
I am trying to automate a batch file to constantly check an FTP site and download uploaded files and delete after the upload.
I have the batch file set up to upload the files to another ftp server when there is a succesfull download, log the entire process and rename/move the log file when complete
The problem i am having is that the batch file will download and delete the files mid-upload leaving me with nothing on the server and nothing locally.
what is the best way to set up the batch file to not download the files unless the person uploading is finished uploading?
Here is what i have so far:
@echo off
:LOOPY
echo username> ftpcmd.dat
echo password>> ftpcmd.dat
echo cd foldername>> ftpcmd.dat
echo mget *.*>> ftpcmd.dat
echo mdelete *.*>> ftpcmd.dat
echo bye>> ftpcmd.dat
echo username> ftpcmd1.dat
echo password>> ftpcmd1.dat
echo cd foldername>> ftpcmd1.dat
echo mput *exc*.*>> ftpcmd1.dat
echo quit>> ftpcmd1.dat
ftp -i -n -s:ftpcmd.dat 192.168.1.1 > ftp.log
find "bytes" ftp.log
set error=%errorlevel%
if not %error%==0 goto end2
ftp -i -n -s:ftpcmd1.dat 192.168.0.1 > ftp2.log
ren ftp.log FTPLOG%_%%date:~4,2%%-%%date:~7,2%%-%%date:~10%%.log
move FTPLOG*.log c:\Logs
:end2
del ftpcmd.dat
del ftpcmd1.dat
goto LOOPY --- i want to script to constantly run and not leave files on the ftp sever for long
Any help will be greatly appreciated
Thanks!
Elliot