Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to move all the files from current_path to current_path/DestinationFolder.

The version of SFTP I'm using is: SFTP protocol version 2

The available commands are:

sftp> help
Available commands:
cd path                       Change remote directory to 'path'
lcd path                      Change local directory to 'path'
chgrp grp path                Change group of file 'path' to 'grp'
chmod mode path               Change permissions of file 'path' to 'mode' 
chown own path                Change owner of file 'path' to 'own'
help                          Display this help text
get remote-path [local-path]  Download file
lls [ls-options [path]]       Display local directory listing
ln oldpath newpath            Symlink remote file
lmkdir path                   Create local directory
lpwd                          Print local working directory
ls [path]                     Display remote directory listing
lumask umask                  Set local umask to 'umask'
mkdir path                    Create remote directory
put local-path [remote-path]  Upload file
pwd                           Display remote working directory
exit                          Quit sftp
quit                          Quit sftp
rename oldpath newpath        Rename remote file
rmdir path                    Remove remote directory
rm path                       Delete remote file
symlink oldpath newpath       Symlink remote file
version                       Show SFTP version
!command                      Execute 'command' in local shell
!                             Escape to local shell
?                             Synonym for help

I don't have mv command. I tried RNFT and didn't work.

Now, I can use rename:

 rename current_path/myFile.txt current_path/DestinationFolder/myFile.txt

and it's OK. But I need to move all (or many) of the files. The following didn't work:

 rename current_path/* current_path/DestinationFolder/

Couldn't rename file "current_path/*" to "current_path/DestinationFolder/": Bad message

Don't have access through SSH so I can't do things like echo "ssh login@server mv * current_path/DestinationFolder/"

I shouldn't mess with this server this is: no scripts, no activities, etc. I'm very limited.

Could you recommend me a way to solve this, please??

NOTE: this is in SOLARIS.

share|improve this question
You can't ask the box's administrator to do this? – cjc Nov 13 '12 at 19:21
No, because I must check the their server many times per day :/ This is for a extremely big financial organization, we are on our own, without their support. – Kani Nov 13 '12 at 19:25
Is everything running on Solaris, or can you run a different client, such as Filezilla, which, while it may not be able to do what you want in one shot, may be able to give you some sort of multi-file select on moves? (Actually, I don't know if Filezilla does that, but there may be other SFTP clients that give you that.) – cjc Nov 13 '12 at 19:28
Everything in Solaris (no GUIs) and through scripts (the operations are constantly made) :/ Thank you! – Kani Nov 13 '12 at 19:30
What happens if you: sftp> !bash or sftp> ! or sftp> !id ? Anything like that work? – Jay Mar 23 '13 at 23:51

i agree with cjc. If you really are limited to above the command that will allow you to download files is put local-path [remote-path] and scp it back. Good link here too.

I would use something like winscp though, makes things a lot easier.

sftp> help put
USAGE: put local-path [remote-path] [-bg | -fg] [-s] [-o] [-r] [-b | -lf]
DESCRIPTION: Upload file.
 -bg   Start (queue) transfer in background.
 -fg   Start transfer in foreground.
 -s    Include subdirectories (recursive).
 -r    Force existing incomplete file to be resumed.
 -o    Force existing file to be overwritten.
 -b    Upload all files as binary; no conversions.
 -lf   Use auto detection upload mode. Text files are uploaded
       in Unix format, with LF as the line delimiter.

 -     If both '-r' and '-o' are specified, resume is tried first,
       and if that fails, overwrite is used.
 -     '-std' and '-t' transfer mode options are also available
       when SFTP version 4 or higher is in use.
share|improve this answer
Thank you. That could be done. But I was looking for an alternative solution. Because if I get the files to my Server, the put it to the destination Server in the destination folder, and delete the originals, if something goes wrong (the copy failed and deleted all the originals, or any other catastrophic event) I have no way back. I though the using rename would be more robust. what you propose is absolutely right and accurate, but could you recommend me another way that does not involve to much transactions between the Servers?. Thank you again. – Kani Nov 13 '12 at 19:57

Your Answer


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.