The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Build a file cleanup reminder tool

Here’s a simple File Cleanup Reminder Tool built in Python. It periodically scans a directory for old files and reminds the user to clean them up if they exceed a certain age threshold.

python
import os import time import datetime from plyer import notification # Configuration TARGET_FOLDER = "C:/Users/YourUsername/Downloads" # Change this to the folder you want to monitor AGE_THRESHOLD_DAYS = 30 # Days after which a file is considered old SCAN_INTERVAL_HOURS = 24 # How often to scan the folder def get_old_files(directory, days_old): now = time.time() threshold = now - (days_old * 86400) old_files = [] for root, _, files in os.walk(directory): for file in files: full_path = os.path.join(root, file) try: last_modified = os.path.getmtime(full_path) if last_modified < threshold: old_files.append(full_path) except Exception as e: print(f"Error checking file {full_path}: {e}") return old_files def send_reminder(file_list): if not file_list: return file_count = len(file_list) message = f"You have {file_count} old file(s) in your cleanup folder.nConsider removing them to save space." notification.notify( title="File Cleanup Reminder", message=message, timeout=10 # seconds ) def main(): while True: print(f"Scanning {TARGET_FOLDER} for files older than {AGE_THRESHOLD_DAYS} days...") old_files = get_old_files(TARGET_FOLDER, AGE_THRESHOLD_DAYS) send_reminder(old_files) print(f"Scan complete. Next scan in {SCAN_INTERVAL_HOURS} hour(s).") time.sleep(SCAN_INTERVAL_HOURS * 3600) # Sleep for configured hours if __name__ == "__main__": main()

How to Use:

  1. Install the plyer package for cross-platform notifications:

    bash
    pip install plyer
  2. Update the TARGET_FOLDER path to the directory you want to monitor.

  3. Run the script, and it will notify you once a day about files older than the defined threshold.

Let me know if you want a GUI version or system tray integration.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About