How to get all the file of a oppoint directory from a FTP
There are no such a method using to download a whole directory in the lib of ' ftplib '. thanks for anybody's help! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get all the file of a oppoint directory from a FTP
John Machin wrote:
> snowf wrote:
> > There are no such a method using to download a whole directory in the
> > lib of ' ftplib '.
> > thanks for anybody's help!
>
> So you'll have to lash one up:
>
> (untested)
>
> Firstly,
> alist = []
> ftpobj.retrlines('list', alist.append)
> should get you a list of filenames.
>
> Secondly,
>
> for fname in alist:
> f = open(fname, "wb")
> ftpobj.retrbinary('RETR ' + fname, f.write)
> f.close()
>
> should do the business. Instead of using f.write as the callback, you
> might like to wrap that in a function that counts the bytes received,
> displays progress, etc.
>
> HTH,
> John
Thanks for you reply!
I will have a try with your suggest and show the result later.
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to get all the file of a oppoint directory from a FTP
Steve Holden wrote: > snowf wrote: > > There are no such a method using to download a whole directory in the > > lib of ' ftplib '. > > thanks for anybody's help! > > > If your Python distrbution contains a "Tools" directory you should look > for the "ftpmirror.py" utility in it. If you don't have Tools then you > can extract them from the Python source tarball. > > regards > Steve > -- > Steve Holden +44 150 684 7255 +1 800 494 3119 > Holden Web LLC/Ltd http://www.holdenweb.com > Skype: holdenweb http://holdenweb.blogspot.com > Recent Ramblings http://del.icio.us/steve.holden Thank you for your reply . : ) -- http://mail.python.org/mailman/listinfo/python-list
