I have couple of text files named as:
temp1.txt
temp2.txt
temp3.txt
temp4.txt
track.txt
I want to delete files only starting with temp and ending with .txt.
I tried using os.remove("temp*.txt") but I'm getting error as:
The filename, directory name, or volume label syntax is incorrect: 'temp*.txt'
What is the right way to do this using python 3.7?
from pathlib import Path
for filename in Path(".").glob("temp*.txt"):
filename.unlink()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With