Python FTP - NameError: name 'mydpa' is not defined

Ej gaikolai at gmail.com
Tue Aug 5 11:35:47 EDT 2008


Hi Fredrik,

Thanks so much for you quick help!!! I googled the os.rename you gave
me and I found solution to solve my problem.

You made my day!




On Aug 5, 10:37 am, Fredrik Lundh <fred... at pythonware.com> wrote:
> Ej wrote:
> > 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
> > name.
>
> > For example in this case:
>
> > from ftplib import FTP
> > ftp=FTP('tgftp.nws.noaa.gov')
> > ftp.login()
> > ftp.cwd('SL.us008001/DF.of/DC.radar/DS.81dpr/SI.kbuf')
> > ftp.retrbinar('RETR sn.last', open('sn','wb').write)
> > ftp.quit()
>
> > 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.
>
> </F>- Hide quoted text -
>
> - Show quoted text -




More information about the Python-list mailing list