I am logged in on a server (using Putty). from there I'm connecting using FTP to another server. I want to copy several folders from the first server to the second server using mput.


ftp> mput folder1 folder2 folder3

But I get "folder1: not a plain file."...and so on. Each of these folders have subfolders, files (some binary, some not).

How can I accomplish what I want without zipping the stuff and then transfer?


Command line FTP is pretty primitive.

You can't recursively send files/folders towards a remote site.

If you want to recreate a directory structure on the remote side the same as the local, you need to manually mkdir each path and use mput * to send everything in that directory to the remote side.

Two options to make this easier:

  1. Stop using the primitive FTP command (ncftp is a good alternative)

  2. Use tar to tar up the folders, send the file and extract on the far side.

  • 1
    +1 for tar->put->untar – dave Nov 4 '17 at 23:06
  • 1
    -1 Because question asks "How can I accomplish what I want without zipping the stuff and then transfer?", implying that the person does not have shell access to the remote machine. – Steen Schütt Nov 24 '17 at 10:50

I made a bash script:

cd /path/to/local/folder/$folder
ftp -in <<EOF
open $ftp_site
user $username $passwd
mkdir $remote/$folder
cd $remote/$folder
mput *

and called it with

find . -type d -exec ./recursive-ftp.sh {} \;

seems to work.


This is not possible with the normal ftp program as mput does not use recursion. You could use ncftp and then call 'mput -r folder'.

Best wishes, Fabian

  • That's exactly what I did recently on an RHEL 5 box. In the EPEL package, the executable is named ncftpput. – Suppressingfire Dec 4 '09 at 20:04
  • Can't change anything in the server's configuration. I'm just an user... – Mircea Dec 4 '09 at 20:10
  • It depends on your client. Not on the server. – halfdan Dec 4 '09 at 21:53
  • I prefer to do it this way. Thank you. – Mojtaba Rezaeian Oct 29 '19 at 16:48

Secure Copy scp has a -r recursive flag that you might find useful.

  • Question is about simple ftp access.. not scp/sftp! – Mojtaba Rezaeian Oct 29 '19 at 16:51

open powershell cd to the directory you want to upload run the following commands:

1. gci -r | % {if ($_.PSIsContainer) {$t = $((($_.fullname -split "\\")[$(((pwd) -split "\\").length)..200]) -join "/"); "mkdir ""$t""`r`nmput ""$t/*"" ""$t"""}} | sc .\mput_all
2. notepad .\mput_all

Paste the results into your ftp window. Enjoy. Also don't forget to add mput * to transfer all the files from the base directory.

  • 6
    Since when does PowerShell run on a Unix system? – Michael Hampton Apr 15 '14 at 0:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy