[Tutor] How do I delete all Files of certain extension type?
mhoy4 at cox.net
Wed Jun 20 18:26:43 CEST 2007
I have a phonebook program that creates .pb files for each entry that is
created. One of the features of the program will be to allow the user to
delete all of the .pb files in the directory. For simplicity I was just
going to have it delete all the .pb files in the same directory I was
I've tried to make a while loop that will delete all the .pb file found
from glob but it obviously is wrong:
Here is what I have so far:
print "Here is a list of all Phonebook files in this directory: "
pb_files = glob.glob('*.pb')
deleteFiles = raw_input("Would you like to delete all .pb files? ")
if deleteFiles == "Yes":
# need to loop thru pb_files and use os.remove
while pb_files > 0:
elif deleteFiles == "No":
Any pointers you can offer would be appreciated.
More information about the Tutor