ftp and python
python.list at tim.thechases.com
Thu Apr 8 15:49:23 CEST 2010
> You could user FTP.voidcmd()
> ftp.voidcmd('RNFT filename.txt')ftp.voidcmd('RNTO newdir/filename.txt')
>>From the rfc:
> RENAME FROM (RNFR)
> This command specifies the old pathname of the file which is
> to be renamed. This command must be immediately followed by
> a "rename to" command specifying the new file pathname.
> RENAME TO (RNTO)
> This command specifies the new pathname of the file
> specified in the immediately preceding "rename from"
> command. Together the two commands cause a file to be
As mentioned in my original reply, that should be what
ftplib.FTP.rename() does under the covers. However, the OP
was asking about copying a file, not renaming a file.
John mentioned the poorly-supported "server-to-server copy", but
from my understanding, I think that still slurps locally and then
pushes it back up elsewhere.
taken from ftplib.py:
def rename(self, fromname, toname):
'''Rename a file.'''
resp = self.sendcmd('RNFR ' + fromname)
if resp != '3':
raise error_reply, resp
return self.voidcmd('RNTO ' + toname)
More information about the Python-list