How do I download a whole folder through FTP in Terminal?
7 Answers
mget
is the closest you can get with the included FTP binary. You have to mkdir and cd/lcd and then get all the files than match a pattern like *
The prompt
toggle may come in handy.
FTP works within a directory, not on directories as containers of files. If you absolutely had to get the job done and ftp was the only tool you could use - you could cobble together an expect
script to drive ftp for you.
Thankfully there are alternatives like scp
|rsync
|wget
to get whole directories worth of files.
-
Ok...so the bottom line is that I can't download a whole folder at one time; I have to download the individual files, right? Commented Jul 22, 2011 at 15:23
-
Yup. Everyone wouldn't be showing wget, sftp, scp and rsync if ftp were up to the task.– bmike ♦Commented Jul 22, 2011 at 15:41
-
-
Oops (sorry) - no. sftp is the same syntax and limitations of ftp - just securing the connection using ssh instead of ftp authentication.– bmike ♦Commented Jul 22, 2011 at 16:47
-
Another way is to use curl
curl ftp://ftp.com/mp3/* --user login:password -o /myfolder/*
I think this is working, or file by file
curl ftp://ftp.com/mp3/mymusic.zip --user login:password -o mymusic.zip
I hope this helped.
-
OK, thank you very much, but is there a way via FTP to do this? Commented Jul 21, 2011 at 23:28
-
-
-
3I'm trying your suggestion but getting this:
curl: (78) RETR response: 550
– OmerCommented Oct 5, 2016 at 5:32 -
1
I am using
wget -r -l 10 --ftp-user='FTP_USER' --ftp-password='FTP_PASSWORD' \
ftp://ftp.server.com/folder_to_download/*
Unfortunately wget
doesn't support parallel downloads.
I had to download 22'000+ webcam pictures from my web server, which is a bit of a challenge for both the Finder and my FTP program CyberDuck.
So I did the following (based on @bmike's answer):
mkdir ~/Desktop/image-dump-myserver
ftp ftp://[email protected]
# enter password
# You're now in the ftp console (where the world is still okay)
# Set the local folder
lcd ~/Desktop/image-dump-myserver
# cd into the desired folder (`ls`, `pwd` etc. all work here)
cd /httpdocs/images
# Toggle the interactive mode
prompt
# Download the desired files (all the images in my case)
mget *.jpg
Then the files are being downloaded into the desired folder:
local: image1433509292_1582.jpg remote: image1433509292_1582.jpg
229 Entering Extended Passive Mode (|||50001|)
150 Opening BINARY mode data connection for image1433509292_1582.jpg (63626 bytes)
100% |***********************************| 63626 1.51 MiB/s 00:00 ETA
226 Transfer complete
63626 bytes received in 00:00 (0.98 MiB/s)
local: image1427279963_0841.jpg remote: image1427279963_0841.jpg
229 Entering Extended Passive Mode (|||50053|)
150 Opening BINARY mode data connection for image1427279963_0841.jpg (67194 bytes)
100% |***********************************| 67194 1.64 MiB/s 00:00 ETA
226 Transfer complete
67194 bytes received in 00:00 (1.04 MiB/s)
local: image1439798493_1783.jpg remote: image1439798493_1783.jpg
229 Entering Extended Passive Mode (|||50357|)
150 Opening BINARY mode data connection for image1439798493_1783.jpg (48876 bytes)
100% |***********************************| 48876 1.80 MiB/s 00:00 ETA
226 Transfer complete
48876 bytes received in 00:00 (996.81 KiB/s)
....
Use scp
(documentation) or sftp
(documentation)
scp -r login@myserverip:/remote/directory/path/ mylocaldirectory
-
That's not what I'm asking. My question is: How do I download a folder via FTP in Terminal? In other words, what commands in FTP do I use to download a folder? Commented Jul 21, 2011 at 21:58
-
2
-
1
-
1
follow this instruction :
type
ftp
then you are in ftp looking like
ftp>
then you open ip of server
ftp> open xx.xxx.xxx.xx
then it will ask for username, you will provide
Name:(your ftp server): your_username
then it wil ask for password
Password: your_password
then you should be logged in and see the ftp> shell again, you can type "ls" to list all files and you can navigate like in inix with cd
when you found your filename you can download it with
ftp> get filename
et voila, the file will be downloaded to the directory you opened shell localy from
you cant download directorys, but you could navigate into your directory and download multiple e.g all files
Task: Download Multiple Files
You need to use mget command as follows to copy multiple files from the remote ftp server to the local system. You may be prompted for a yes/no (Y/N) answer before transferring each file (you can disable prompt by passing the -i option to ftp client). To download all files, enter: ftp> mget *
information from http://www.cyberciti.biz/faq/linux-unix-ftp-commands/ cheers
-
The ftp unix tool has been removed from OS X (in Sierra, I think?).– benwiggyCommented Aug 30, 2019 at 7:29
lcd /dirtodownload
prompt
mget *
From @Besi answer, was doing the job directory by directory, but I needed to download a large site via ftp.
Wget options works with a tradtional ftp server, (unlike scp or sftp) Using the -m mirror option recursively downloaded all files.
wget -m --user=username --password='pswd' ftp://123.4.5.678