Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧹 Smart Folder Cleaner Pro — AI-Powered PC File Organizer

License: MIT GitHub stars Platform Python AI

AI-powered PC file organizer and cleaner that automatically categorizes your files, detects duplicates, cleans up junk, and organizes your folders with smart rules. No more messy desktops or lost documents.


📖 Table of Contents


✨ Features

  • AI Content Classification — Analyzes file content (not just extension) to categorize into 50+ categories: Documents, Images, Videos, Audio, Archives, Code, Projects, Fonts, Templates, and more
  • Duplicate & Near-Duplicate Detection — Perceptual hashing for images, content hashing for docs, fuzzy match for text files. Finds exact copies AND similar files
  • Smart Cleanup — Identifies temp files, cache, old downloads (>90 days), empty folders, log files, crash dumps, and duplicate backups
  • Auto-Organize Rules Engine — Rule-based organizer: move, copy, rename, archive, compress, or delete based on type, size, date, pattern matching
  • Visual Dashboard — Interactive pie charts, storage trends over time, file type breakdown, largest files list, cleanup recommendations
  • Safe Mode with Full Undo — Every action is previewed before execution. Full undo/redo history — revert any change with one click
  • Scheduled Cleanup — Set it and forget it: daily/weekly/monthly auto-clean with configurable rules
  • Exclusion Manager — Exclude specific folders, file types, or patterns from scanning and cleanup
  • Export Reports — Save scan results and organization history as HTML, PDF, or CSV
  • Multi-Folder Monitoring — Watch multiple folders for changes and auto-organize new files in real-time

🔮 How It Works

                        ┌─────────────────────────────┐
                        │   Smart Folder Cleaner   │
                        │        (Python)          │
                        └──────────┬──────────────────┘
                                   │
              ┌────────────────────┼────────────────────┐
              ▼                    ▼                    ▼
     ┌──────────────┐    ┌──────────────┐    ┌──────────────┐
     │   Scanner   │    │  Classifier  │    │  Duplicate   │
     │  (File tree)│───►│  (AI Engine) │───►│  Detector    │
     └──────────────┘    └──────┬───────┘    └──────┬───────┘
                                   │                    │
              ┌────────────────────┘                    │
              ▼                                         ▼
     ┌──────────────┐                          ┌──────────────┐
     │   Rules     │                          │   Preview    │
     │   Engine    │─────── Review ──────────►│   & Apply    │
     └──────────────┘                          └──────┬───────┘
                                                      │
                                                      ▼
                                             ┌──────────────┐
                                             │    Undo     │
                                             │   History   │
                                             └──────────────┘

Scan Pipeline

  1. Scanner walks the folder tree, collects metadata (size, date, hash, type)
  2. AI Classifier reads content samples, assigns category (Document/Image/Video/etc.)
  3. Duplicate Detector compares hashes, finds exact copies + near-duplicates
  4. Rules Engine matches files against user-defined rules (move, delete, archive...)
  5. Preview shows all proposed changes with diff view — approve or reject each
  6. Apply executes approved actions with full undo support

🧠 AI Classification

Smart Folder Cleaner uses two classification modes:

Mode 1: Local Classifier (Offline, Default)

  • Uses file extension + magic bytes + filename pattern analysis
  • Categorizes into 50+ types: PDF, DOCX, XLSX, JPG, PNG, MP4, ZIP, TAR, PY, JS, CSS, HTML, JSON, XML, CSV, PPTX, ODT, EPUB, MOBI, FONTS, TTF, OTF, EXE, MSI, DLL, SRC, MD, YAML, ENV, LOG, TMP, CACHE, BAK, ISO, DMG, APK, DEB, RPM, ...
  • Zero dependencies — works completely offline
  • Speed: ~10,000 files/second

Mode 2: AI Classifier (Online, Enhanced)

  • Uses OpenAI / Gemini API to analyze file content and context
  • Understands semantic categories: "Invoice", "Contract", "Screenshot", "Backup", "Project Config"
  • Auto-generates folder names and subfolder structures
  • Speed: ~50 files/second (API dependent)
Feature Local AI
Speed 10K files/s 50 files/s
Categories 50+ (by type) Unlimited (semantic)
Internet Not needed Required
Cost Free API usage fees
Schema detection ✅ Smart sorting

🔍 Duplicate Detection

Method Algorithm Use Case
Exact SHA-256 hash Identical files (byte-perfect)
Fuzzy (Images) Perceptual hash (pHash) Similar images, thumbnails, resized versions
Fuzzy (Text) Cosine similarity + MinHash Similar documents with minor edits
Name Similar Levenshtein distance Files with similar names (e.g., report(1).pdf)
Size + Date Threshold comparison Potential duplicates within time windows

Results are grouped with confidence scores:

Duplicates Found: 47 groups (124 files, 2.3 GB)
  ├─ 📄 report-final.pdf (2.4 MB) ──► report.pdf (2.4 MB) [100% match]
  ├─ 🖼️ IMG_2024.jpg ──► IMG_2024(2).jpg [100%] ──► IMG_2024_thumb.jpg [89% match]
  ├─ 📁 backup_2024-01-15.zip ──► backup_2024-01-16.zip [95% match]
  └─ 📝 notes_v1.txt ──► notes_v2.txt [72% match (similar text)]

💻 Tech Stack

Component Technology
Language Python 3.10+
UI CustomTkinter
AI OpenAI / Gemini API + local classifier
Image Hashing ImageHash + Pillow
Text Similarity scikit-learn (cosine similarity)
File Watching watchdog
Charts Matplotlib
Storage SQLite
Reports ReportLab (PDF) + Jinja2 (HTML)
Platform Windows / Linux

🚀 Installation

Windows

git clone https://github.com/zougar99/Smart-Folder-Cleaner-Pro.git
cd Smart-Folder-Cleaner-Pro
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
python main.py

Linux

git clone https://github.com/zougar99/Smart-Folder-Cleaner-Pro.git
cd Smart-Folder-Cleaner-Pro
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python main.py

📄 Configuration

Edit config.yaml:

scan:
  include_paths:
    - C:\Users\<USER>\Desktop
    - C:\Users\<USER>\Downloads
    - C:\Users\<USER>\Documents
  exclude_paths:
    - C:\Windows
    - C:\Program Files
  exclude_patterns: ['*.sys', '*.dll', 'node_modules/']
  max_depth: 10
  follow_symlinks: false

classifier:
  mode: local               # local | ai
  ai_provider: openai      # openai | gemini
  api_key: <YOUR_API_KEY>  # only needed for AI mode

cleanup:
  temp_files_older_than: 30  # days
  recycle_bin: true
  empty_folders: true
  compress_archives: false

schedule:
  enabled: false
  frequency: weekly          # daily | weekly | monthly
  day: sunday
  time: "03:00"

rules:
  - name: Organize Images
    match: type == Image
    action: move
    target: "C:\Pictures\{year}\{month}"
  - name: Delete Old Logs
    match: pattern == "*.log" AND age > 90
    action: delete
  - name: Archive Projects
    match: type == Code AND age > 365
    action: compress
    target: "C:\Archives\{name}.zip"

🧰 Usage Guide

First-Time Scan

Step Action
1 Launch: python main.py
2 Click Add Folder and select directories to scan
3 Choose classification mode (Local / AI)
4 Toggle duplicate detection on/off
5 Click Start Scan — progress bar shows real-time status
6 Review results in the Dashboard tab
7 Switch to Actions tab to preview all changes
8 Approve or reject each action
9 Click Apply to execute
10 Check History tab to undo any action if needed

💻 CLI Commands

# Scan specific folders
python main.py --scan C:\Users\You\Desktop C:\Users\You\Downloads

# Quick cleanup (temp + cache only)
python main.py --clean --quick

# Full scan with AI classification
python main.py --scan . --ai --api-key YOUR_KEY

# Find duplicates only
python main.py --dedup --scan D:\Photos

# Dry run (preview only, no changes)
python main.py --scan . --dry-run

# Export report
python main.py --scan . --export report.html

# Run as a scheduled task (once)
python main.py --scan . --apply --headless

📜 Rules Engine

Rules use a simple DSL:

match: type == Image AND size > 5MB AND age > 30
action: compress
target: "C:\Compressed\{year}-{month}"

Match Conditions

Condition Operators Example
type ==, != type == Document
ext ==, !=, in ext in ["jpg", "png", "gif"]
size >, <, >=, <= size > 100MB
age >, < age > 365 (days)
pattern == (glob) pattern == "*.tmp"
name contains, matches name contains "backup"

Actions

Action Description
move Move file to target folder
copy Copy file to target folder
rename Rename with pattern {date}_{name}
delete Move to Recycle Bin
compress Create ZIP archive
tag Apply color tag / label

🖼 Screenshots

(Screenshots coming soon. PRs welcome!)

Dashboard Scan Results Rules Editor
Dashboard Scan Rules

🔄 Roadmap

  • 🟢 Real-time folder watcher (auto-organize new files)
  • 🟡 Cloud backup integration (Google Drive, OneDrive)
  • ⚫ Android/iOS companion app
  • ⚫ Photo duplicate detection by EXIF data
  • ⚫ File versioning system (like macOS Time Machine)
  • ⚫ Network drive / NAS support

❓ FAQ

Is it safe? Can it delete my files?

Yes, it's safe. By default, deleted files go to Recycle Bin. All changes are previewed before execution. Every action is fully undoable from the History tab.

Does it work on network drives?

Yes — any locally accessible drive (including NAS and network shares) can be scanned.

How accurate is the AI classification?

Local mode is ~95% accurate for file-type categories. AI mode is ~98% accurate and can understand semantic categories (e.g., "Invoice" vs "Contract").

Can I run it automatically?

Yes — enable the scheduler in config.yaml for automatic daily/weekly/monthly cleanup.

How much storage can I recover?

Typical users recover 5-50 GB on first scan (temp files, duplicates, old downloads). Heavy users on first scan have recovered up to 200+ GB.


🚧 Troubleshooting

Problem Solution
Scan is too slow Switch to Local classification; exclude system folders; reduce depth
AI classification fails Check API key in config; ensure internet connection
Duplicate detection misses files Enable fuzzy matching in Settings; try all hash methods
Rules not firing Check condition syntax in config; verify file matches criteria
Undo history lost Undo data is stored for 30 days in ~/.sfcp/undo/
High memory usage Reduce scan scope; close other apps; use 64-bit Python

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push (git push origin feature/amazing-feature)
  5. Open a Pull Request

📐 License

Distributed under the MIT License. See LICENSE for more information.


Made with 🧹 and ❤️ by zougar99

About

AI-powered PC file organizer and cleaner with smart categorization,

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages