在 SFTP 会话中重命名文件

shr*_*ani 3 sftp rename

这是SFTP文件传输的一部分。

以下是步骤:

  1. 检查带有.csv扩展名的文件并将它们放到本地目录中。
  2. 之后,将它们移动到远程连接中的另一个文件夹。

尝试使用该rename命令,但它会引发错误“失败”

尝试-b在 sftp 中使用批处理文件选项,但看起来rename命令需要特定的文件名而不是一组文件。

那么我该如何实现呢?

roa*_*ima 6

对我有用,因此您需要提供有关问题的更多信息:

chris@localhost$ finger 2> file.txt
chris@localhost$ sftp remotehost
Connected to remotehost.
sftp> ls -l file.txt
Can't ls: "/home/chris/file.txt" not found
sftp> ls -l file.tmp
Can't ls: "/home/chris/file.tmp" not found

# So the file doesn't exist on the remote in either form

sftp> put file.txt file.tmp
Uploading file.txt to /home/chris/file.tmp
file.txt                                                      100%  501     0.5KB/s   00:01
sftp> ls -l file.txt
Can't ls: "/home/chris/file.txt" not found
sftp> ls -l file.tmp
-rw-r-xr--    0 1001     1001          501 Aug 12 16:35 file.tmp

# It has arrived as file.tmp

sftp> rename file.tmp file.txt
sftp> ls -l file.txt
-rw-r-xr--    0 1001     1001          501 Aug 12 16:35 file.txt
sftp> ls -l file.tmp
Can't ls: "/home/chris/file.tmp" not found

# And been successfully renamed
Run Code Online (Sandbox Code Playgroud)