Re: [BATCH WORLD] ftp file transfer...
- I'm not affiliated w/ the site I'm referring. Perhaps it will fit the
(Embedded image moved to file: pic02543.gif)
<Sethfleming@yaho To: email@example.com
Subject: [BATCH WORLD] ftp file transfer...
Please respond to
I have a small batch file which uses mget *.* to transfer files from
the remote server to my local machine. Currently the files are not
many so it doesn't take long but in the future I would like it to
only transfer those files that are not on my local machine. If a
file already exist on my local machine I would like it to just skip
that file and check the next. I know this might be complicated for
batch but I don't have any experience in Perl or other "real"
languages. Just checking to see if there might be a way that I'm
not thinking of.
To Post a message, send it to: batchworld@...
To Unsubscribe, send a blank message to: batchworld-unsubscribe@...
Yahoo! Groups Sponsor
Yahoo! Groups Links
To visit your group on the web, go to:
To unsubscribe from this group, send an email to:
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]
- --- In firstname.lastname@example.org, "SethFleming" <Sethfleming@y...>
> I have a small batch file which uses mget *.* to transferUnless you can find an ftp client with a bit more smarts than
> files from the remote server to my local machine. Currently
> the files are not many so it doesn't take long but in the
> future I would like it to only transfer those files that
> are not on my local machine. If a file already exist on
> my local machine I would like it to just skip that file
> and check the next. I know this might be complicated for
> batch but I don't have any experience in Perl or other "real"
> languages. Just checking to see if there might be a way
> that I'm not thinking of.
the MS offering, this is a bit difficult. One way to do it is
1. Use an ftp script to get a list of the files on the ftp server
2. Process the ftp output to extract the file names
2. Get a list of the files on the local machine
3. Use FINDSTR to create a list of the files on the server
but not on the local machine
4. Create and execute an ftp script to get the individual
files from the ftp server.
Below is an example batch file that will do the above. Be warned
however that you will have to fine tune it for the sort of
output your server gives. In my case, the ftp server I tested
against gives lines which end in 0x0d, 0x0d, 0xoA which
confused FOR no end and required some jumping thru' hoops to
extract the file names from the ftp log file. You might be able
to do it easier.
Also be aware that FINDSTR can be a bit flaky at times. You
might run into problems with characters in file names that it
wants to interpret as its own metacharacters.
:: get a directory listing from ftp server
ftp -s:%ftps% > %ftplog%
:: extract file names from %ftplog%
type nul> %ftplist%
for /f "tokens=* skip=14" %%a in (%ftplog%) do (
if /i "!line:~0,3!"=="ftp" goto :dirlist
call echo "%%line%%">> %ftplist%
:: get a directory listing from local source
type nul> %srclist%
for /f "tokens=*" %%a in ('dir /b /a-d %srcdir%') do (
:: create the ftp script to get the missing files
for /f "tokens=*" %%a in (
'findstr /i /l /v /g:%srclist% %ftplist%') do (
echo get %%a>>%ftps%
:: Go get 'em
ftp -s:%ftps% >> %ftplog%
:: Create connection commands for an ftp session
(echo open %ftpserver%
echo cd /uploads