By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,364 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,364 IT Pros & Developers. It's quick & easy.

ftplib question

P: n/a
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

Apr 7 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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', 'f**@example.com')
workdir = server.cwd("/pub/datfiles/english") ## Set the current
directory
server.delete("*.*")

End Example:

I hope it helps

Apr 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.