Answers for "Deleting files which start with a name"

0

Deleting files which start with a name

my_dir = # enter the dir name
for fname in os.listdir(my_dir):
    if fname.startswith("version"):
        os.remove(os.path.join(my_dir, fname))
Posted by: Guest on September-28-2021
0

Deleting files which start with a name

import os, glob
for filename in glob.glob("mypath/version*"):
    os.remove(filename)
Posted by: Guest on September-28-2021

Code answers related to "Deleting files which start with a name"

Python Answers by Framework

Browse Popular Code Answers by Language