Upload directories recursively with NcFTP

8707

Author: Peter Leung

I recently had to upload some content to a Web site, and the only access available was via FTP. I needed an FTP client capable of uploading a directory structure recursively. I found what I needed in an application called NcFTP.

I started by looking into Mozilla Firefox, but to my surprise, Firefox supports only FTP downloads, not uploads. Mozilla, on the other hand, does support uploads, but it can upload only one file at a time.

Next, I turned to command-line FTP clients. Again, the standard FTP command doesn’t support recursive directory upload. Fortunately, many graphical and command-line FTP clients do, including NcFTP, yafc, and LFTP. I picked NcFTP.

After installing the software, connect to your host anonymously by entering the ncftp command followed by the hostname:

ncftp ftp.somedomain.com

or if you need to log in with a valid username, use the -u and -p parameters:

ncftp -u username -p passwordftp.somedomain.com

A successful connection puts you in an NcFTP shell. If you’ve used the standard FTP command before, you should feel right at home here. I’ll presume you’re familiar with basic FTP commands such as dir and cd. You can use the lls and the lcd commands to list and navigate the local working directory.

NcFTP supports autocompletion for both commands and filenames. For instance, you can type in the first few characters of a filename and then press Tab to fill in the rest of the name automatically.

Recall that my main goal was to upload a directory structure. Use the put -R command to do a recursive directory upload:

ncftp /path > put -R somedir

Standard FTP also supports a put command, but it’s limited to uploading single files.

Similarly, you can download a directory recursively using the NcFTP get -R command:

ncftp /path > get -R somedir

More handy features

If you FTP to the same sites regularly, you can save time by using NcFTP’s bookmark feature. Bookmarks store the connection information, including the username, the password, the hostname, and the target directory location.

To create a bookmark on a particular directory location, first navigate to that directory and then enter the bookmark command followed by a name to identify the bookmark. For example, type these commands to bookmark /path/somedir and name it topsecret:

ncftp /path > cd somedir
ncftp /path/somedir > bookmark topsecret

A bookmark editor lets you open, edit, delete, replicate, and add bookmarks. Invoke the editor by entering the bookmarks command with no parameters:

ncftp /path > bookmarks

Once you create a bookmark, you can connect to the corresponding host and directory quickly by using the bookmark name. Login is automatic because the bookmark stores the username and password.

For instance, you can connect using a bookmark named topsecret by entering this command in the Linux shell:

ncftp topsecret

Alternatively, you can open a connection while inside the NcFTP shell:

ncftp> open topsecret

Wrapping it up

File Transfer Protocol (FTP) was once a commonly used method for transferring files over the Internet, but recent security concerns have lessened its use in favor of the more secure SSH File Transfer Protocol (SFTP) or Secure Copy (SCP). Nevertheless, FTP may be the only access available to you on occasion.

NcFTP is loaded with useful features. I’ve touched on only the basics. If you ever require an FTP client more powerful than the standard FTP command, consider NcFTP.