I want this function to delete files. It does this correctly, but it also deletes folders, which I do not want.
I also get an error during execution:
Access is denied: 'C:/temp3\\IDB_KKK
In folder temp3 i have:
IDB_OPP.txt
IDB_KKK - folder
Code:
def delete_Files_StartWith(Path,Start_With_Key):
my_dir = Path
for fname in os.listdir(my_dir):
if fname.startswith(Start_With_Key):
os.remove(os.path.join(my_dir, fname))
delete_Files_StartWith("C:/temp3","IDB_")