Recursively Download Folders using FTP with wget in UNIX (even SSH)

Mon, Oct 15, 2007

Programming & Code


Okay, so you don’t have SSH access to your server, but you do have FTP access to it, and you need *all* the files in a folder.

Worse, your directory structure is many levels deep, and extremely messy. Normal FTP won’t cut it, because command-line FTP doesn’t do recursive downloading of folders. Turning off interactive mode and using mget doesn’t work too.

The easiest solution? Use wget to recursively download folders using FTP. Here’s the wget command:

wget -r ftp://username:password@yourftphostname.com/directory1/directory2/

You can replace yourftphostname.com with an IP too. So with wget, and the -r flag (for Recursive) that’s all that you need to recursively download folders using FTP. Took me a while to figure that out, but what a relief when I finally discovered how to :D

wget -r -c ftp://username:password@yourftphostname.com/directory1/directory2/

And if you happen to get disconnected, don’t fret, because wget has the -c flag too, which probably stands for Continue. This useful wget flag actually provides a resume function, which is very handy when you are transferring large files!

(Of course you really shouldn’t be running plain old insecure ftp when sftp is available…)

Similar Posts:

Tags: , , ,
, , ,

This post was written by:

- Alvin is a Singaporean who's interested in marketing, techy stuff and likes to just figure out how the two can work with each other. On top of his blog, you can also follow him on Twitter.

Get Alvin's Report On How To Blog Successfully - Free!

3 Comments For This Post

  1. Anon Says:

    saved me – thanks

  2. CrusaderAD Says:

    Brilliant… this post saved me at last. Works great!

  3. Max Says:

    Awesome!! Thanks!

Leave a Reply

*