SFTPセッションでファイル名を変更する

SFTPセッションでファイル名を変更する

これはSFTPファイル転送。

次のように進んでください。

  1. 拡張子があるファイルを確認し、.csvローカルディレクトリに配置します。
  2. 次に、リモート接続の別のフォルダに移動します。

コマンドを試しましたが、renameエラーが発生しました。「失敗する」

sftpのバッチファイルオプションを試しましたが、コマンドがファイルセットではなく特定のファイル名を期待しているよう-bです。rename

ではどうすればいいですか?

ベストアンサー1

私に役立つので、問題に関する追加情報を提供する必要があります。

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

おすすめ記事