I have a folder where want to delete the files on it when they reaches 5 files (or if they are older than 5 days). so far I have tried this:
path_file = r'C:\...\new folder'
files = os.listdir(path_file)
for file in files [:5]:
os.remove(file)
This code gives the next error:
os.remove(file)
FileNotFoundError: [WinError 2] The system cannot find the file specified file