How FTP Multiple Files from the Command Line

Many times I am challenged to move many similar files from one server to another.  Either I have to remote-desktop on to the server (Windows), or have a session on the server (AIX, Linux).  In these situations, I do not have a nice GUI utility, like FTP Voyager, setup to move my files.  There are some good basic commands in FTP that make life easier to move many like files.

C:\ ftp <my server name>

ftp> bin

ftp> prompt no

ftp> mget <start of the like files> *

Below are commands that I use to move multiple files at in a couple commands.

binary or bin: when you set to binary mode, you’ll receive a message “200 Type set to I”.  The default mode for FTP is ASCII.  Binary mode transmits the raw bytes of a file.  This is useful when moving zipped or executable file.  If you transmit your executable or zipped file in ASCII mode, you may find it corrupted on the receiving server.  To save time & typing, you can type “bin”, and the FTP utility will recognize it as the command “binary”.

prompt no: by default the prompt is set on to check if you want the download the file.  When you set your prompt mode to no, your will get an message “Interactive mode OFF”.  By setting the prompt to no, the FTP utility will automatically download multiple files without prompting.

Below is an example of being prompted for each file & why you may want to avoid this (you have to type either y or n for each file):

— very bad if you have to move hundreds to thousands of files

mget: this command can retrieve multiple files at a time.  View some of the example below:

FTP> mget file01 file02 file03

separate each file with a space

FTP> mget filename*

FTP> mget *.txt

start or finish with the common characters in the file name, and the star (*) can be used as a wildcard character

mput: this command is used like mget to upload multiple file to the remote computer

FTP> mput file01 file02 file03

separate each file with a space

FTP> mput filename*

FTP> mput *.txt

start or finish with the common characters in the file name, and the star (*) can be used as a wildcard character

Why I write this:

When I started working more with linux & AIX operating systems, I remember spending a lot of time to put together all the commands that I would need to upload system patches or to script the movement of log files.  This week, cleaning up my personal folder, I found the notes I had to put these together.  My hope is that these notes helps someone cut down on the number of message board they have to search to find the commands need to accomplish these tasks.

12 Comments