retrbinary ! how does it work ?

blancmunier1 at yahoo.FR blancmunier1 at yahoo.FR
Thu Feb 1 04:17:34 EST 2007


Hello dear community !

I'm a bit ashamed to ask such an easy question, but I didn't find my
answer on previous posts.
I'd like to copy files with FTP protocol in a subdirectory.
So far, my code look like that :

  import ftplib
  session = ftplib.FTP('222.33.44.55','usr','pwd')
  session.cwd('/')
  files = session.nlst()
  for file in files:
    session.retrbinary('RETR '+file, open(file, 'wb').write)

It does work but the files are copied in the same directory as the
python file. And I would like to copy the file in this relative
directory :  ../archives
For example, if the python file is in this directory : C:\SCOR\Bat\,
the FTP files gotta be in C:\SCOR\archives\ .

Can anyone help me.

Thanks a lot by advance.

Yvan Blancmunier




More information about the Python-list mailing list