Hi Team,
I am using below code, but file is not getting deleted.
print(file) is printing below.
def Delete_Folder(site,tbl,Constant_folder):
import os
path = f"{Constant_folder}\{site}\{tbl}"
for file_name in os.listdir(path):
# construct full file path
file = path + file_name
print(file)
if os.path.isfile(file):
print('Deleting file:', file)
os.remove(file)
if __name__ == "__main__":
Delete_Folder("AU","tbl5","D:\Python\sample_folder")
output
D:\Python\venv\Scripts\python.exe D:\Python\test2.py
D:\Python\sample_folder\AU\tbl5abc - Copy (2).txt
D:\Python\sample_folder\AU\tbl5abc - Copy (3).txt
D:\Python\sample_folder\AU\tbl5abc - Copy (4).txt
D:\Python\sample_folder\AU\tbl5abc - Copy (5).txt
D:\Python\sample_folder\AU\tbl5abc - Copy (6).txt
D:\Python\sample_folder\AU\tbl5abc - Copy (7).txt
D:\Python\sample_folder\AU\tbl5abc - Copy.txt
D:\Python\sample_folder\AU\tbl5abc.txt