This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady
What I Built
Most developers have a Downloads folder that looks like a digital landfill: dozens of document(1).pdf, Screenshot 2026-10-21.png, and camera uploads like IMG_20241019_142356.jpg.
Organizing them manually is tedious, and simple extension-moving scripts fail because they can't understand what a file actually contains.
In honor of International Sloth Day and this week's theme β Slow and Steady: build something with open-source AI that rewards laziness β I built SlothSort.
SlothSort is a lightweight CLI that uses a local open-weight model (llama3.2) via Ollama to scan messy folders, understand file context, clean up names into readable kebab-case, and sort everything into category folders.
Core Features
- π§ Contextual Sorting: Classifies files using both extensions and text header previews (peeking at the first few lines of text/CSV/code).
- π·οΈ Clean Renaming: Standardizes messy timestamps and downloads (
Screenshot 2026-10-21 000814.pngβscreenshot-2026-10-21-000814.png). - π¦₯ True Sloth Mode (
--watch): Runs quietly in the background, tidying up new downloads automatically while you take a nap. - π Deduplication (
--dedupe): Uses fast SHA-256 matching to isolate duplicate downloads (invoice (1).pdf) into aDuplicates/folder. - π‘οΈ Defensive by Default: Safe dry-run previews by default, collision protection (
-1,-2), and instant 1-command rollback (slothsort undo).
Demo
Here is a live terminal session running against a messy directory:
$ slothsort ~/Downloads --dedupe
βββββββββββββββββ π¦₯ slothsort v1.0.0 βββββββββββββββββ
β π /Users/deepa/Downloads β
β βοΈ DRY-RUN Model: llama3.2 β’ Offline Inference β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Taxonomy Breakdown
ββββββββββββββββββββββ¬βββββββββββ¬βββββββββββββ¬βββββββββββββ¬βββββββββββββββββ
β Category β Files β Size β Renamed β Inference β
ββββββββββββββββββββββΌβββββββββββΌβββββββββββββΌβββββββββββββΌβββββββββββββββββ€
β π¦ Archives β 3 β 45.0 MB β 1 β 1/3 local β
β π΅ Audio β 2 β 18.5 MB β 2 β rules β
β π» Code β 5 β 0.2 MB β 2 β rules β
β π Data β 3 β 1.1 MB β 3 β rules β
β π¨ Design β 2 β 24.0 MB β 2 β rules β
β π Documents β 7 β 2.8 MB β 6 β 1/7 local β
β π Duplicates β 2 β 1.4 MB β 0 β dedupe β
β πΌοΈ Images β 4 β 6.9 MB β 4 β rules β
β βοΈ Installers β 2 β 157.9 MB β 2 β rules β
β π¬ Videos β 1 β 240.0 MB β 1 β 1/1 local β
ββββββββββββββββββββββΌβββββββββββΌβββββββββββββΌβββββββββββββΌβββββββββββββββββ€
β Total β 31 β 497.8 MB β 23 β β β
ββββββββββββββββββββββ΄βββββββββββ΄βββββββββββββ΄βββββββββββββ΄βββββββββββββββββ
ββ Proposed Directory Hierarchy βββββββββββββββββββββββββββββββββββββββββββββββ
β π Downloads/ β
β βββ π Documents/ (7 files) β
β β βββ analytics_october_metrics.csv β analytics-october-metrics.csv β’ β
β β β Financial data report β
β β βββ budget_forecast_q4.xlsx β budget-forecast-q4.xlsx β’ standardized β
β β β kebab-case β
β β βββ final_report_FINAL_v3_USETHISONE.docx β β
β β β final-report-final-v3-usethisone.docx β’ standardized kebab-case β
β β βββ meeting_notes_oct.txt β meeting-notes-oct.txt β’ standardized β
β β kebab-case β
β βββ π Duplicates/ (2 files) β
β β βββ document(2).pdf β Duplicates/document(2).pdf β’ duplicate of β
β β β document(1).pdf β
β β βββ IMG_20241020_083211.jpg β Duplicates/IMG_20241020_083211.jpg β’ β
β β duplicate of IMG_20241019_142356.jpg β
β βββ πΌοΈ Images/ (4 files) β
β β βββ Screenshot 2026-10-21 000814.png β β
β β β screenshot-2026-10-21-000814.png β’ standardized kebab-case β
β β βββ wallpaper_4k_mountain.jpg β wallpaper-4k-mountain.jpg β’ β
β β standardized kebab-case β
β βββ βοΈ Installers/ (2 files) β
β βββ ABDownloadManager_1.11.1_windows_x64.exe β β
β β abdownloadmanager-1.11.1-windows-x64.exe β’ standardized kebab-case β
β βββ VSCodeUserSetup-x64-1.92.0.exe β vscodeusersetup-x64-1.92.0.exe β’ β
β standardized kebab-case β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββ Next Step ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Dry-run preview complete. No files were modified on disk. β
β β
β To apply these changes, run: β
β slothsort "~/Downloads" --execute --dedupe β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
When you pass --execute, the moves happen atomically. If you ever change your mind:
$ slothsort undo ~/Downloads
ββ Rollback Complete ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β Successfully restored 31 file(s) to original locations. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Code
The complete codebase, documentation, and automated test suite are open-sourced on GitHub:
π GitHub Repository: D9292S/slothsort
slothsort/
βββ pyproject.toml # Modern Hatchling package configuration
βββ README.md # Full documentation and command reference
βββ LICENSE # MIT License
βββ .slothsort.toml.example # Configuration template for user overrides
βββ slothsort/
β βββ __init__.py # Version metadata
β βββ config.py # Taxonomy mapping, model configurations, defaults
β βββ scanner.py # Filtering, snippet extraction, SHA-256 duplicate hashing
β βββ categorizer.py # Ollama JSON inference + Algorithmic Hallucination Guard
β βββ organizer.py # Collision resolution (-1, -2), moves, atomic undo manifest
β βββ cli.py # Rich terminal UI, diff tree, watch mode, commands
βββ demo/
β βββ simulate_mess.py # Demo script to generate 31 realistic messy files
βββ tests/
βββ test_scanner.py # Filtering, snippets, duplicate detection tests
βββ test_safety.py # Hallucination guard & name preservation tests
βββ test_parser.py # Resilient JSON parsing tests (lists, dicts, markdown)
βββ test_organizer.py # Collision resolution & end-to-end rollback tests
How I Built It
SlothSort is built with Python 3.10+, Ollama, Meta Llama 3.2 (3B), Click, Rich, and Pydantic.
Technical Highlights
- Local Inference: Files are batched and sent to Ollama with strict JSON schemas enforced by Pydantic.
- Content Sniffing: For ambiguous text/code/data files under 2 MB, the scanner peeks at the first 300 characters to provide the model with grounding context.
-
The Hallucination Guard (
is_safe_rename): During testing, I caught a 3B model edge case: when given a batch containing multiple installers, Llama 3.2 occasionally cross-pollinated names (trying to renameABDownloadManager.exetobitdefender.exe). I wrote an algorithmic safety guard that verifies suggested names never borrow tokens from other files in the batch, falling back to safe formatting if cross-contamination is detected. -
Safety & Testing: Includes an atomic rollback log (
.slothsort-undo.json) and 12 unit tests inpytestverifying parsing, collision handling, and hallucination rejection.
Why Does Open Innovation Matter?
For personal file management, local open-source AI is fundamentally superior to closed cloud APIs:
- π Absolute Privacy: Your Downloads folder contains tax drafts, bank statements, and personal records. With local models, zero bytes leave your machine.
- πΈ Zero Recurring Cost: Organizing thousands of files costs \$0.00 in API tokens.
- βοΈ 100% Offline: Operates in airplane mode, on trains, or without internet.
- ποΈ Model Portability: Swap models freely based on your hardware (
--model llama3.2,--model phi3, or--model mistral). - π‘οΈ Resilient Fallback: If Ollama is offline or files exceed 500 MB, SlothSort gracefully falls back to deterministic rules. It never crashes.
My Agent Session
I built SlothSort through an iterative agent pair-programming session with an AI coding assistant. The agent helped scaffold the initial Click/Rich CLI architecture, iterate on small-model prompt engineering with Ollama, and write the 12-test pytest suite that verified the algorithmic hallucination guard.
The Lazy Payoff
Manually sorting an 800-file Downloads folder usually takes 45 minutes of tedious drag-and-drop.
With SlothSort, it takes 5 seconds with one command β or zero effort if you leave --watch running in the background.
Top comments (0)