ftplib question

E

eight02645999

hi
my purpose is just to connect to an FTP server and delete all files in
a directory
Is there a way using ftplib module? something like ftp.delete("*") ?
another way i can do is using LIST to list out all the files in that
directory, grab the filename, append to an array, then do a for loop to
delete one by one.
using the ftplib retrlines('LIST') , it shows me all the lines with
-rw-r--r-- 1 user grp 6302 Apr 7 15:30 some file
how can i get only the filename?
thanks
 
R

RunLevelZero

Well I am not too familiar with ftplib but I have done some minimal
work.

Example:

try:
server=FTP()
server.connect('ftp.mcafee.com', 21)
except:
print "Could not connect to server"
raw_input("Hit Enter to quit:")
sys.exit(0)
login = server.login('anonymous', '(e-mail address removed)')
workdir = server.cwd("/pub/datfiles/english") ## Set the current
directory
server.delete("*.*")

End Example:

I hope it helps
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top