Only Download Fully Uplaoded files from FTP

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Egulk
Posts: 3
Joined: 10 Feb 2010 10:14

Only Download Fully Uplaoded files from FTP

#1 Post by Egulk » 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

Egulk
Posts: 3
Joined: 10 Feb 2010 10:14

Re: Only Download Fully Uplaoded files from FTP

#2 Post by Egulk » 13 Feb 2010 21:58

Anybody have any thoughts?

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

Re: Only Download Fully Uplaoded files from FTP

#3 Post by DosItHelp » 14 Feb 2010 00:57

Egulk,
I don't know how to check if a files is done uploading. Here an alternative that may work for you:

Have the upload script upload the files into a different folder. When done uploading have same upload script move the file over to the target folder with a single FTP "rename" command.
That way you wouldn't have partially uploaded files in your remote target folder.

DosItHelp :?:

Egulk
Posts: 3
Joined: 10 Feb 2010 10:14

Re: Only Download Fully Uplaoded files from FTP

#4 Post by Egulk » 14 Feb 2010 20:48

when would i remove the file from the ftp server?

i was thinking of doing two passes on the file sizes on the server comparing them against each-other for changes and only downloading when they are the same but i cant figure out how to do that...

do you think something like that would work?

and if yes how would i do that?

thanks!

Post Reply