Bootstrap FreeKB - FTP and Secure FTP (FTPS, SFTP) - upload multiple files or directories using the mput command
FTP and Secure FTP (FTPS, SFTP) - upload multiple files or directories using the mput command


There are a number of ways to securely transfer files between systems.

  • The PSFTP command line tool can be used to for SFTP (Secure FTP) to securetly transfer files between systems, from a remote system to your PC, or vice versa. This has the advantage of being able to transfer files between Linux, Mac and Windows systems.
  • The scp command (Secure Copy Protocol) could be used to securely transfer files between Linux systems.

There are a number of different tools that can be used to connect to an FTP / FTPS / SFTP server.

  • Windows or Linux command line prompt
  • Scripting tool (e.g. Bash, Perl, PowerShell, Python, et cetera)
  • The PSFTP command line tool PSFTP.exe (see Installing PuTTY PSFTP)

Let's say you want to transfer C:\Users\john.doe\foo.txt and C:\Users\john.doe\bar.txt from your local PC to the remote FTP system. The put command can be used to transfer the files. If you only specify the file on your local PC, the file will be uploaded to the present working directory on the remote FTP system.

ftp > put C:\Users\john.doe\foo.txt
local: C:\Users\john.doe\foo.txt => remote:/tmp/foo.txt

ftp > put C:\Users\john.doe\bar.txt
local: C:\Users\john.doe\bar.txt => remote:/tmp/bar.txt

 

However, better yet, the mput command command can be used to upload both foo.txt and bar.txt.

ftp > mput C:\Users\john.doe\foo.txt C:\Users\john.doe\bar.txt
local: C:\Users\john.doe\foo.txt => remote:/tmp/foo.txt
local: C:\Users\john.doe\bar.txt => remote:/tmp/bar.txt

 

Likewise, the mput command can be used to transfer multiple directories and the contents of the directories from your local system to the remote system. In this example, the "foo" and "bar" directories are transferred to the remote system.

ftp > put -r C:\Users\john.doe\foo C:\Users\john.doe\bar
local: C:\Users\john.doe\foo => remote:/tmp/foo
local: C:\Users\john.doe\foo => remote:/tmp/bar

 

The wildcard character can be used to transfer every file in your present working directory (pwd) on your local PC to the working directory on the remote system.

ftp > mput *
local: C:\Users\john.doe\foo.txt => remote:/tmp/foo.txt
local: C:\Users\john.doe\bar.txt => remote:/tmp/bar.txt

 

When the upload has completed, you should simply be presented with the prompt again. Use the dir (directory) command or ls (list) command to list the contents of the present working directory on the remote FTP system, to verify that the files or directories were successfully transferred.

ftp > ls
-rw-rw-r--   1   john.doe john.doe   50   Dec 4 19:07   foo.txt
-rw-rw-r--   1   john.doe john.doe   50   Dec 4 19:07   bar.txt

 

Or, the lpwd (local present working directory) command can be used to determine your current working directory on your local PC (not on the remote FTP system).

ftp> lpwd
Current local directory is C:\Program Files (x86)\PuTTY

 

If you need to change your local working directory, use the lcd (local change directory) command to move into the C:\Users\john.doe directory on your local PC (not on the remote FTP system).

ftp> lcd C:\Users\john.doe
New local directory is C:\Users\john.doe

 

Use the pwd (remote present working directory) command to determine your current working directory on the remote FTP system (not on your local PC).

ftp> pwd
Remote directory is /home/john.doe

 

If you need to change the working directory on the remote FPT system, use the cd (change directory) command.

ftp> cd /tmp
Remote directory is now /tmp

 

Use the exit command to disconnect.

ftp > exit

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a2832f in the box below so that we can be sure you are a human.