ftplib with unknown file names

Discussion in 'Python' started by rbt, Jan 10, 2005.

  1. rbt

    rbt Guest

    How can I use ftplib to retrieve files when I do not know their names? I
    can do this to get a listing of the directory's contents:

    ftp_server.retrlines('LIST')


    The output from this goes to the console and I can't figure out how to
    turn that into something I can use to actually get the files (like a
    list of file names). I read a bit about the callback function that can
    be passed to retrlines but I couldn't figure out how to use it.

    Any help is appreciated.

    Thanks!
    rbt, Jan 10, 2005
    #1
    1. Advertising

  2. rbt

    Jeremy Jones Guest

    rbt wrote:

    > How can I use ftplib to retrieve files when I do not know their names?
    > I can do this to get a listing of the directory's contents:
    >
    > ftp_server.retrlines('LIST')
    >
    >
    > The output from this goes to the console and I can't figure out how to
    > turn that into something I can use to actually get the files (like a
    > list of file names). I read a bit about the callback function that can
    > be passed to retrlines but I couldn't figure out how to use it.
    >
    > Any help is appreciated.
    >
    > Thanks!


    <ftp object>.nlst(argument) will return a list of file names. Here are
    the docs for the nlst command:

    http://www.python.org/doc/current/lib/ftp-objects.html


    HTH,

    Jeremy Jones
    Jeremy Jones, Jan 10, 2005
    #2
    1. Advertising

  3. rbt

    rbt Guest

    Jeremy Jones wrote:
    > rbt wrote:
    >
    >> How can I use ftplib to retrieve files when I do not know their names?
    >> I can do this to get a listing of the directory's contents:
    >>
    >> ftp_server.retrlines('LIST')
    >>
    >>
    >> The output from this goes to the console and I can't figure out how to
    >> turn that into something I can use to actually get the files (like a
    >> list of file names). I read a bit about the callback function that can
    >> be passed to retrlines but I couldn't figure out how to use it.
    >>
    >> Any help is appreciated.
    >>
    >> Thanks!

    >
    >
    > <ftp object>.nlst(argument) will return a list of file names. Here are
    > the docs for the nlst command:
    >
    > http://www.python.org/doc/current/lib/ftp-objects.html
    >
    >
    > HTH,
    >
    > Jeremy Jones


    Very good Jeremy! Thank you for pointing that out. It works great.
    rbt, Jan 10, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. fBechmann
    Replies:
    0
    Views:
    391
    fBechmann
    Jun 10, 2004
  2. Peter A. Schott
    Replies:
    0
    Views:
    875
    Peter A. Schott
    Feb 10, 2005
  3. Replies:
    7
    Views:
    645
    Lyell Haynes
    May 2, 2006
  4. Vincent Arnoux
    Replies:
    1
    Views:
    236
    Arnaud Bergeron
    Aug 11, 2006
  5. Calan
    Replies:
    6
    Views:
    115
    Michael Winter
    Apr 6, 2004
Loading...

Share This Page