ftplib with unknown file names

R

rbt

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!
 
J

Jeremy Jones

rbt said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top