A Python utility that automatically organizes files into categorized folders based on file types, with rule-based classification and real-time monitoring.
Project description
SFO File Organizer
A Python utility that automatically organizes files into categorized folders based on their file types, with support for rule-based classification, structured logging, and real-time monitoring.
Features
- 📁 Smart Classification
- Rule-based classification (keywords take priority)
- Extension-based fallback classification (supports PHP, TS, JSX, etc.)
- ⚙️ Customizable Categories - Easy to add custom file categories and rules
- 🔄 Duplicate Handling - Automatic renaming for duplicate filenames
- 📊 Statistics - Summary report after organization
- 🧪 Dry-Run Mode - Preview changes without moving files
- 📝 Structured Logging - Console and file logging with configurable levels
- 🖥️ Modern Desktop UI - Sleek dark-themed interface with:
- Scheduling: Automate organization to run daily.
- Flatten Directory: Undo organization by moving files back to the root (only targets organizer-created folders).
- Watch Mode: Real-time folder monitoring.
- ↩️ Undo Support - Easily revert any organization session (auto-cleans empty folders)
- 🧠 Smart Context - Auto-detects folder purpose by name (Photos, Documents, etc.) for specialized sorting
Platform Compatibility
| Platform | Pre-built Executable | Run from Source |
|---|---|---|
| Windows | ✅ .exe available |
✅ Supported |
| macOS | ✅ Available via GitHub Releases | ✅ Supported |
| Linux | ✅ Available via GitHub Releases | ✅ Supported |
Note: Pre-built executables for all platforms are automatically generated via GitHub Actions and attached to each Release.
macOS / Linux Setup
-
Install Python 3.8+ (usually pre-installed on Linux, download from python.org for macOS)
-
Clone and install dependencies:
git clone https://github.com/pjames-tech/sfo-file-organizer.git cd sfo-file-organizer pip install -r requirements.txt
-
Run the GUI:
python gui.py -
Or run the CLI:
python organizer.py --source ~/Downloads
Building Your Own Executable (Optional)
If you want to create a native executable for your platform:
# Install PyInstaller
pip install pyinstaller
# Build the executable
pyinstaller --onefile --windowed gui.py
The executable will be created in the dist/ folder.
Architecture
sfo-file-organizer/
├── organizer.py # Main CLI and orchestration
├── gui.py # Desktop GUI application (tkinter)
├── app_config.py # Configuration and file categories
├── rules.py # Rule-based classification engine
├── scheduler.py # Windows Task Scheduler integration
├── history.py # Undo/redo history management
├── logging_config.py # Logging configuration
├── run_organizer.bat # Batch script helper
├── requirements.txt # Dependencies
└── tests/ # Unit tests
Classification Priority
- Keyword Rules - Custom rules take priority.
- File Extension - Standard classification based on file type.
Installation
Option 1: Install via pip (Recommended for all platforms)
pip install sfo-file-organizer
Then run:
sfo-file-organizer # Launch GUI
sfo # Shortcut for GUI
sfo-cli --source ~/Downloads # CLI mode
Option 2: Download Pre-built Executable
| Platform | Download |
|---|---|
| Windows | SFO-File-Organizer-Windows.exe |
| macOS | SFO-File-Organizer-macOS.zip |
| Linux | SFO-File-Organizer-Linux |
Option 3: Run from Source
git clone https://github.com/pjames-tech/sfo-file-organizer.git
cd sfo-file-organizer
pip install -r requirements.txt
python gui.py
Usage
Quick Start
- Install using one of the methods above.
- Launch the application (GUI or CLI).
- Select the folder you want to organize.
- Click "Organize Now" and watch your files get sorted!
👁️ Watch Mode
Watch Mode monitors your source folder in real-time. Any file you drop into the folder will be automatically categorized and moved instantly.
- GUI: Just toggle the "Watch Mode" switch.
- CLI: Run
python organizer.py --watch
Desktop GUI
Launch the graphical interface:
python gui.py
Features:
- 📂 Browse and select any folder to organize
- 🚀 Organize Now - One-click file organization
- 👁️ Preview Changes - See what will happen before committing
- 🧹 Flatten - Move files out of organizer-created subfolders back to the root (preserves pre-existing folders)
- ⏰ Automation - Schedule daily organization tasks
- ↩️ Undo Last - Restore files to their original locations and clean up empty folders
- 📋 Activity log with colored output
- 🧠 Smart Context - Enable to sort images by year or documents by type based on folder name
- ⌚ Watch Mode - Real-time folder monitoring
CLI Mode
# Organize Downloads folder (in-place)
python organizer.py --source ~/Downloads
# Dry-run (preview without moving files)
python organizer.py --dry-run --source ~/Downloads
# Undo last organization
python organizer.py --undo
# View history
python organizer.py --history
CLI Options
| Flag | Short | Description |
|---|---|---|
--source |
-s |
Source directory to organize |
--dest |
-d |
Destination directory (default: same as source) |
--dry-run |
-n |
Preview changes without moving files |
--in-place |
-i |
Organize within source folder (default) |
--watch |
-w |
Monitor folder and organize in real-time |
--undo |
Undo the last organization | |
--history |
Show organization history | |
--log-level |
-l |
Set logging level (DEBUG, INFO, WARNING, ERROR) |
--no-log-file |
Disable logging to file |
Examples
# Preview what would happen
python organizer.py --dry-run --source ./messy_folder
# Quick organize current downloads
python organizer.py --source ~/Downloads
# Start watching a folder
python organizer.py --watch --source ~/Downloads
Configuration
File Categories (app_config.py)
FILE_CATEGORIES = {
"Images": [".jpg", ".jpeg", ".png", ".gif", ...],
"Documents": [".pdf", ".doc", ".docx", ".txt", ...],
"Videos": [".mp4", ".mkv", ".avi", ...],
"Code": [".py", ".js", ".php", ".ts", ".jsx", ...],
# Add custom categories here
}
Keyword Rules (rules.py)
KEYWORD_RULES = {
"invoice": "Documents", # Files with "invoice" go to Documents
"screenshot": "Images", # Files with "screenshot" go to Images
# Add custom rules here
}
Testing
# Install pytest
pip install pytest
# Run all tests
pytest tests/ -v
Automatic Scheduling (Windows Task Scheduler)
Run the organizer automatically on a schedule using the included batch script.
Quick Setup
-
Edit
run_organizer.batto customize your source/destination folders:"C:\Python314\python.exe" organizer.py --source "%USERPROFILE%\Downloads" --dest "%USERPROFILE%\Downloads" --log-level INFO
-
Create the scheduled task (run in PowerShell as admin):
schtasks /create /tn "Smart File Organizer" /tr "C:\path\to\run_organizer.bat" /sc daily /st 12:00 /f
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sfo_file_organizer-1.0.1.tar.gz.
File metadata
- Download URL: sfo_file_organizer-1.0.1.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69ae28d04d76ea7a47e15824156548f7653c1452d595706bfec70ccaaa53ae0e
|
|
| MD5 |
9835913f573b37417fc79c06cdeb1fd1
|
|
| BLAKE2b-256 |
fde9c6d94939c1efc8d9d9012f95934af7f372e99901ea2cb18113c1e8555f38
|
Provenance
The following attestation bundles were made for sfo_file_organizer-1.0.1.tar.gz:
Publisher:
publish-pypi.yml on pjames-tech/sfo-file-organizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sfo_file_organizer-1.0.1.tar.gz -
Subject digest:
69ae28d04d76ea7a47e15824156548f7653c1452d595706bfec70ccaaa53ae0e - Sigstore transparency entry: 882172739
- Sigstore integration time:
-
Permalink:
pjames-tech/sfo-file-organizer@7b0679139cc74dca888a629af646f7ad882d128c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/pjames-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7b0679139cc74dca888a629af646f7ad882d128c -
Trigger Event:
release
-
Statement type:
File details
Details for the file sfo_file_organizer-1.0.1-py3-none-any.whl.
File metadata
- Download URL: sfo_file_organizer-1.0.1-py3-none-any.whl
- Upload date:
- Size: 32.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16dc54cfbc5396ae76a0df7aa1d89f745889203277670daab59d3748478de581
|
|
| MD5 |
87f3e6162b61848e985dd23e5ff7b025
|
|
| BLAKE2b-256 |
8f34dffece52292c60adce1de242f99675834b048557aff1597402b22e086808
|
Provenance
The following attestation bundles were made for sfo_file_organizer-1.0.1-py3-none-any.whl:
Publisher:
publish-pypi.yml on pjames-tech/sfo-file-organizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sfo_file_organizer-1.0.1-py3-none-any.whl -
Subject digest:
16dc54cfbc5396ae76a0df7aa1d89f745889203277670daab59d3748478de581 - Sigstore transparency entry: 882172793
- Sigstore integration time:
-
Permalink:
pjames-tech/sfo-file-organizer@7b0679139cc74dca888a629af646f7ad882d128c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/pjames-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7b0679139cc74dca888a629af646f7ad882d128c -
Trigger Event:
release
-
Statement type: