deleting files which start with a name

Solutions on MaxInterview for deleting files which start with a name by the best coders in the world

showing results for - "deleting files which start with a name"
Giacomo
06 Aug 2016
1my_dir = # enter the dir name
2for fname in os.listdir(my_dir):
3    if fname.startswith("version"):
4        os.remove(os.path.join(my_dir, fname))
5
Edgar
16 Jun 2018
1import os, glob
2for filename in glob.glob("mypath/version*"):
3    os.remove(filename) 
4