Reputation: 135
I am using pysftp to access files on server using python.
conn = sftp.Connection(host = 'host', username = 'user', password = 'password')
remotepath = '/tmp/random/NAME_LATEST.zip'
localpath = '/home/tmp/Desktop/NAME.zip'
conn.put(localpath,remotepath)
conn.close()
What I want to do is, before putting the file NAME_LATEST, I want to rename the file already present with the name 'NAME_LATEST' to 'NAME+' and then put the new file as NAME_LATEST. What is a way to rename the file?
Upvotes: 3
Views: 10923
Reputation: 470
For pysftp 0.2.8, rename documentation is available at API page. There is nothing in cookbook for rename
.
Upvotes: 1
Reputation: 26022
conn.rename(remote_src, remote_dest)
: rename a file or directory on the remote host.
Upvotes: 7