Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

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.

share|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

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
share|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

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/*
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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