30
5
I need to upload a full folder using FTP. Is there is any option for transferring a folder and all of its contents at once?
30
5
I need to upload a full folder using FTP. Is there is any option for transferring a folder and all of its contents at once?
24
If you're using a standard command-line ftp client, the MPUT
command will allow you to transfer all files matching a (shell glob-style) pattern, so MPUT *
will send all files in the current directory. There is also MGET
to retrieve files matching a pattern.
By default, both MPUT
and MGET
will prompt for whether to transfer each file before doing so. You'd probably want to turn off prompting with the "PROMPT" command (no argument; it's a toggle).
24
You can use ncftpput. Do the following:
Install ncftp:
yum install ncftp
yum is lowercase.
Alternatively:
apt-get install ncftp
2. Execute the following command:
ncftpput -R -v -u "ftp-username" ftp.website.com ftp-upload-path local-path/*
The Yum should be changed to yum - as it is case-sensitive. – olekeh – 2017-10-26T07:34:49.620
1
Here are all CLI options for ncftpput: http://www.ncftp.com/ncftp/doc/ncftpput.html
– Pepijn Olivier – 2017-12-12T17:37:02.547What I like about this solution: automatable! – twigmac – 2020-02-11T08:51:37.197
8
Use an FTP client such as LeechFTP or FileZilla or something similar. Many people swear by CuteFTP, but it's shareware last I checked. All support transferring a whole folder including directory structure.
1
+1 for FileZilla: http://filezilla-project.org/download.php?type=client
– William Jackson – 2011-04-12T14:23:52.8635
note: my answer was posted at StackOverflow. That's why it references a "coding" solution. – Chase Florell – 2011-05-15T01:20:43.087
2
I'll offer an answer which - though it is pure brute force and not elegant in the slightest - was the only thing that worked for me on the command line. I created a list of the files, and put them into a script:
generate your list of files:
find my-dir -exec echo "put /Users/username/"{} {} \;
copy and paste them into the script:
#!/bin/bash
hostname="my-ftp-host"
username="username"
password="password"
ftp -in $hostname <<EOF
quote USER $username
quote PASS $password
binary
cd 123456
{COPY THE LIST HERE}
quit
EOF
2
A simple tutorial for other Windows newbies like me who wind up here:
The easiest way to upload an entire folder (with all subfolders and files in them) is:
ncftpput -u *yourUserNameHere* -p *yourUserPasswordHere* -R *www.yourWebsite.com* / _C:\yourFolderDirectoryHere\\*_(as one line).
Note that:
-R
is a flag for "recursive"; it makes the command copy all subfolders recursively/
(slash) is your website's root directoryC:\yourFolderDirectoryHere\*
selects everything inside C:\yourFolderDirectoryHere
looks nice, but the server banned my IP saying i made 800 connections in short interval. no way to reduce number of connections. ANOTHER problem is that i do not know how to skip uploading if destination file exist already. – 16851556 – 2019-10-21T20:37:38.367
1
Check this out.
You can also programmatically create a folder on the server, and then upload all files to that new folder.
The linked SO question has been removed. – cxw – 2017-11-13T12:06:04.153
0
The target dir is a zip file. You can copy the full zip file into the ftp server using below code.
//Taking source and target directory path
string sourceDir = FilePath + "Files\\" + dsCustomer.Tables[0].Rows[i][2].ToString() + "\\ConfigurationFile\\" + dsSystems.Tables[0].Rows[j][0].ToString() + "\\XmlFile";
string targetDir = FilePath + "Files\\Customers\\" + CustomerName + "\\" + SystemName + "\\";
foreach (var srcPath in Directory.GetFiles(sourceDir))
{
//Taking file name which is going to copy from the sourcefile
string result = System.IO.Path.GetFileName(srcPath);
//If that filename exists in the target path
if (File.Exists(targetDir + result))
{
//Copy file with a different name(appending "Con_" infront of the original filename)
System.IO.File.Copy(srcPath, targetDir + "Con_" + result);
}
//If not existing filename
else
{
//Just copy. Replace bit is false here. So there is no overwiting.
File.Copy(srcPath, srcPath.Replace(sourceDir, targetDir), false);
}
}
That's nice, but your program doesn't compile. – DavidPostill – 2016-06-15T17:32:23.563
0
My answer is variation of @dgig 's answer.
You can list all the files and save them (including put command) into a file:
find my-dir -exec echo "put /Users/username/"{} {} > list.txt \;
and then use sftp to process the file:
sftp -C -b sftpbatchfile.txt name@server
-C
is for compression, -b
is for batch file
This does not use FTP as asked. The sftp
program uses the SFTP protocol which is a different protocol although it has some letters in common. And you didn't edit the enter code here
leftover. – dave_thompson_085 – 2017-03-25T16:30:29.680
0
FileZilla is great for this. If you don't want to download/install anything, this can be done with Internet Explorer. Go into the advanced options, and select Enable FTP folder view (outside of Internet Explorer)
. Then you can point an explorer window at your FTP server and drag-and-drop files and folders between explorer windows.
0
Firefox has a plug-in called FireFtp that is a nice ftp client.
This question originally came from stackoverflow, so I feel that it should be the accepted answer. Though the original asker seems to have vanished so isn't going to accept one.... – codetaku – 2014-08-20T15:17:10.423
Warning: the FTP command line client that comes with Windows doesn't support passive mode so using this technique may waste your time. It did in my case since I needed to upload files and was using the Windows command line w/ natively installed tooling. – sean2078 – 2017-09-21T02:29:53.067
1It will transfer all the plain files in the current directory but it will not transfer recursively any directories that are present. It will just ignore them silently – bergercookie – 2019-02-15T18:09:09.410