Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On the remote FTP server, I have a set of files in the directory remote.dir1. I would like to move all the files in that directory to remote.dir2.

I am using lftp and was trying something like this:

lftp> mv remote.dir1/* remote.dir2/

It does not work and displays: Access failed: 550 remote.dir1/*: The filename, directory name, or volume label syntax is incorrect.

I also tried:

lftp> glob -a mv remote.dir1/* remote.dir2/

which displays the usage message: Usage: mv <file1> <file2>

However, moving single file works: lftp> mv remote.dir1/file1 remote.dir2/

As a last resort, we can construct a file containing a set of lftp mv commands and source it.
Are there any solutions I am not aware of?
Or, are there any capable command line tools for the task?

Edit: I am restricted to FTP environment, so only solutions using FTP are acceptable due to the environmental constraint.

share|improve this question
    
When you say 'it does not work' are you getting any errors? –  Drew Khoury Aug 21 '13 at 7:56
    
yes, in this particular case i'm using lftp, it throws me this line: Access failed: 550 remote.dir1/*: The filename, directory name, or volume label syntax is incorrect. –  cychoi Aug 21 '13 at 8:01
add comment

4 Answers 4

It appears that lftp only supports the glob syntax with commands accepting a single argument, so mv, which requires two, is out.

With FTP, your server might allow for extended commands, especially the execution of a limited command set via SITE EXEC or similar means - check the FTP server's documentation, its help (SITE HELP) or the login banner. These however are not standardized, so if the solution needs to be FTP-server-agnostic, scripting based on the output of the file list seems like the best idea.

share|improve this answer
add comment

rsync is great for moving files from one machine to another (or even between the same machine).

rsync -avz -e "ssh -i /key/path/key.rsa" user@1.2.3.4:/path/on/remote/server/ /path/on/local/server

This command supplies a private key, and connects to a machine. It grabs files from the remote directory, and copies them to the local directory. You can also do the reverse of this by switching the source and destination.

share|improve this answer
2  
The question is about using an FTP client to move a server directory's files –  the-wabbit Aug 21 '13 at 7:50
    
OP also stated: "Are there any solutions I am not aware of? Or, are there any capable command line tools for the task?". rsync sounds pretty capable to me. –  Drew Khoury Aug 21 '13 at 7:51
    
The question is about moving files. OP happened to try FTP but that's not the only way. –  Drew Khoury Aug 21 '13 at 7:53
    
@DrewKhoury Sorry for not being clear enough. I am restricted to FTP protocol only. One of reasons is because the FTP server is a Windows machine. I will update the question on that. Thanks :) –  cychoi Aug 21 '13 at 7:54
add comment
up vote 0 down vote accepted

For documentation purpose, I will post the steps I used to complete the task. Any better solutions are much appreciated. ;-)

Note: this solution uses the lftp FTP client. You may have to install it on your machine before you can proceed.

Solution:

lftp> renlist remote.dir1/ | "sed 's/\(.*\)/mv \"\1\" \"remote.dir2\/\"/'" > list  
lftp> source list  
lftp> !rm list  

Or, the one-linerTM:

lftp> renlist remote.dir1/ | "sed 's/\(.*\)/mv \"\1\" \"remote.dir2\/\"/'" > list && source list && !rm list
share|improve this answer
add comment

I thought FTP was more or less dead. It's been close to 5 years since I've used it, and it was on the way out 10 years ago.

That said, I always found the ncftp family of command line tools very friendly, and I expect this would "just work".

I'm not going to set up an FTP server for the purposes of verifying this, but give it a try. There's a lot else to like about ncftp (At least from version 2 on).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.