I want to delete all files with the extension .bak in a directory. How can I do that in Python?
I want to delete all files with the extension .bak in a directory. How
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Via
os.listdirandos.remove:Using only a single loop:
Or via
glob.glob:Be sure to be in the correct directory, eventually using
os.chdir.