Python FTP - NameError: name 'mydpa' is not defined
fredrik at pythonware.com
Tue Aug 5 16:37:07 CEST 2008
> I have a similar problem. I need to download the same file every hour
> so it will be nice to be able to rename the downloads with a variable
> For example in this case:
> from ftplib import FTP
> ftp.retrbinar('RETR sn.last', open('sn','wb').write)
> Question: How to achive rename the downloaded files as sn1, sn2,
> sn3.... or with a timestamp?
you're downloading to the file name you pass to open ("sn" in your
case), so to download to a different file, just pass in another name.
to rename an existing file on the local file system, use os.rename.
More information about the Python-list