469,304 Members | 2,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

ftplib question

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
1 1237
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.

Similar topics

3 posts views Thread by python | last post: by
2 posts views Thread by Harlin Seritt | last post: by
reply views Thread by vedran | last post: by
1 post views Thread by Laszlo Nagy | last post: by
1 post views Thread by Jon Bowlas | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.