Operating System - Microsoft
1752660 Members
5717 Online
108788 Solutions
New Discussion юеВ

Batch file to Get New Files Only through FTP

 
Murad Al Sharq
Occasional Advisor

Batch file to Get New Files Only through FTP

Hi there

I want to create a batch file which Get (mget) the newly added Files only, from specific directory on UNIX server to local folder on windows server using FTP, and this batch file will be scheduled on the windows server to run daily to load the new files.
help me plz
5 REPLIES 5
avizen9
Esteemed Contributor

Re: Batch file to Get New Files Only through FTP

Hello,

i have some indirect solusion for this.
share out that specific directory in hpux (using by samba)map that drive in your windows box and then use robocopy with below option, robocopy will only copy diff files.

robocopy w:\ g:\ /E /SEC /LOG:Log1.log

here g= is your unix drive
w: = is your local windows drive
Log1.log is log file which will generate

let me know how it goes,
Steven E. Protter
Exalted Contributor

Re: Batch file to Get New Files Only through FTP

Shalom,

There is an example of ftp batch scripting in this link:
http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1237891232149+28353475&threadId=36861

You can put any command you want before the EOF put get, any ftp command.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Murad Al Sharq
Occasional Advisor

Re: Batch file to Get New Files Only through FTP

Thanks a lot for your support
I have reached the following

1- The following is the batch file which has the name "ftp_executable.bat". it contains the following:

ftp -n -s:ftp_import.txt 10.32.253.73
exit

2- The following is the text file which has the name "ftp_import.txt". it contains the following:

user

lcd D:\The coming files from FTP
cd /home/the outgoning files from ftp
prompt
mget *.CSV
bye


Everything is running well

But still I want to modify this batch to get only the newly added CSV file, not all the files (*.CSV). this is now my only issue.
Steven Schweda
Honored Contributor

Re: Batch file to Get New Files Only through FTP

If you're writing a Windows batch script,
then you might do better asking about it in
a Microsoft Windows forum.

> [...] only the newly added CSV file [...]

You could try to get a long-format listing
from the FTP server ("dir"?), then extract a
list of the files which meet your selection
criteria, and finally fetch the desired
files.

I don't see how you would be able to make
this work using "mget". One "get" command
per file would seem to be needed.

It might be easier if some of the work were
done on the Unix (not a well-defined term, by
the way) side. One might, for example,
create a new directory every day, and fill it
with the day's new files (or links to them).
Then, a simple FTP get-everything script
could do the job.
OldSchool
Honored Contributor

Re: Batch file to Get New Files Only through FTP

consider using rsync / rsync for windows. its designed to do such things automatically (i.e. get new / changed files from one system to another).

while doing such w/ ftp is possible, its going to take scripting, in your case on the windows side.