Using the ftp lib to rename a file

Thomas Wouters thomas at xs4all.net
Sun May 27 10:11:53 EDT 2001


On Sun, May 27, 2001 at 06:35:12AM -0700, Henri de Feraudy wrote:

> Can anyone show me a sample illustrating how I can use the ftp lib
> from my client station to rename a file on the server?
> The ftplib doc is a bit minimal.

It's really as minimal as the docs show, though. You connect to an FTP
server:

  import ftplib
  conn = ftplib.FTP("my.host.com", "user", "passwd")

And you send the rename command:

  conn.rename("/my/old/name", "/my/new/name")

Don't forget to use fully qualified pathnames, or conn.cwd() to the right
directory before doing the rename.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list