Add Speaking parts.

This commit is contained in:
Cristiano Ferreira
2023-06-29 22:44:03 +01:00
parent 0b661fe108
commit 0a53f2c1b8
3 changed files with 132 additions and 15 deletions

16
helper/file_helper.py Normal file
View File

@@ -0,0 +1,16 @@
import os
import datetime
from pathlib import Path
def delete_files_older_than_one_day(directory):
current_time = datetime.datetime.now()
for entry in os.scandir(directory):
if entry.is_file():
file_path = Path(entry)
file_modified_time = datetime.datetime.fromtimestamp(file_path.stat().st_mtime)
time_difference = current_time - file_modified_time
if time_difference.days > 1:
file_path.unlink()
print(f"Deleted file: {file_path}")