SFTP:将许多文件从一个文件夹移动(重命名)到另一个文件夹(不是一个一个)

Kan*_*ani 9 solaris unix shell sftp

我需要将所有文件从current_path移动到current_path/DestinationFolder

我使用的SFTP 版本是:SFTP 协议版本 2

可用的命令有:

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
Run Code Online (Sandbox Code Playgroud)

我没有mv命令。我试过RNFT并没有奏效。

现在,我可以使用重命名:

 rename current_path/myFile.txt current_path/DestinationFolder/myFile.txt
Run Code Online (Sandbox Code Playgroud)

没关系。但我需要移动所有(或许多)文件。以下方法无效:

 rename current_path/* current_path/DestinationFolder/

Couldn't rename file "current_path/*" to "current_path/DestinationFolder/": Bad message
Run Code Online (Sandbox Code Playgroud)

无法通过SSH访问,因此我无法执行诸如 echo "ssh login@server mv * current_path/DestinationFolder/" 之类的操作

我不应该弄乱这个服务器,这是:没有脚本,没有活动等。我非常有限。

你能推荐我的方式来解决这个问题,

注意:这是在 SOLARIS 中。

Sc0*_*ian 2

我同意cjc的观点。如果您确实仅限于上述内容,则允许您下载文件的命令是 put local-path [remote-path] 并将其 scp 回来。这里的链接也很好。

我会使用像winscp这样的东西,让事情变得容易得多。

sftp> help put
USAGE: put local-path [remote-path] [-bg | -fg] [-s] [-o] [-r] [-b | -lf]
DESCRIPTION: Upload file.
PARAMETERS:
 -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.

NOTES:
 -     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.
Run Code Online (Sandbox Code Playgroud)