I'm trying to set up a script that will synchronise all images in a remote FTP directory with a local directory that I can run on a regular basis to make sure I have all new images added to the remote directory. I've been trying a solution using wget but I just can't seem to get the syntax right. Here is what I have:

wget -r -N --no-remove-listing -nd ftp://user:password@ftp.server.com/images/

All this seems to do is create a local index.html file with a list of links to remote files (which I don't want). How do I modify this command so it just downloads all the images in the remote directory? Alternatively, is there another unix command I can try to synchronise images from a remote FTP site?

link|improve this question
feedback

3 Answers

Somebody suggested to me to use lftp command (http://lftp.yar.ru/lftp-man.html) like this:

lftp -c 'open ftp.server.com; user username password; mirror -e --only-missing images .; quit'

Seems to work nicely and it's built into most flavours of Unix.

link|improve this answer
If this worked for you, click the green checkmark to mark it as the accepted answer. – Wuffers May 24 '11 at 23:30
feedback

You could try also ncftpget from the ncftp package. See http://www.ncftp.com/ but try to install a ncftp package for your distro.

From "man ncftpget"

-R      Recursive mode; copy whole directory trees.

You  can retrieve an entire directory tree of files by using the -R flag.  However, this will work only if the remote FTP server is a UNIX server, or emulates UNIX's list output.
   Example:

       $ ncftpget -R ftp.ncftp.com /tmp /pub/ncftp
link|improve this answer
I've not used this command before - if you run it again will it ignore any files on the remote FTP server that already exist on the local file system? – Stephen Feb 16 '11 at 11:41
Sorry, I don't remember it, just try it out. – rems Feb 16 '11 at 16:40
feedback

If you want to use WGET, try using the A switch to specify the accepted file extensions:

wget -r --accept=jpg,gif,png ftp://user:password@ftp.foobar.com/blah/*
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.