SlothSort 以本機小模型整理散落檔案
🦥 SlothSort
Amit Rawal 的 SlothSort 是一款本機運行的開源檔案整理工具,會讀取散落檔案的內容並建議檔名和分類資料夾,待用戶確認後才移動檔案。它透過 Ollama 在本機執行 moondream 和 qwen2.5:3b,按檔案類型使用模型或規則分類,不需雲端、API key 或帳戶。
Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥
Tidies your messy folder while you nap. Runs 100% on your laptop.
SlothSort looks at the loose files in a folder (your Desktop, Downloads, anywhere), reads what is inside them, and suggests a clear name and the right folder for each one. You review the plan, change anything you like, and press one button. Every run can be undone.
It uses small open-weight models running locally through Ollama. No cloud, no API key, no account. Your resumes, invoices and screenshots never leave your machine.
Built for the DEV "Slow and Steady" challenge (International Sloth Day 2026).
How it works
folder ──► scanner ──► planner ──► review in browser ──► mover ──► history (undo)
│ │
│ ├─ videos / installers / zips → sorted by type (no AI needed)
│ ├─ images → moondream describes them → qwen2.5 decides
│ └─ PDFs / docx / text / code → qwen2.5 reads the start and decides
└─ pulls a short text sample from each file (pypdf, docx XML, plain text)
Part
File
What it does
Scanner
slothsort/scanner.py
Lists loose files and reads a ~1500-character sample from each one
Brain
slothsort/brain.py
Talks to Ollama; describes images; asks for {folder, new_name, reason} as JSON
Planner
slothsort/planner.py
Builds the plan file by file, with a cache so unchanged files are never re-analysed
Mover
slothsort/mover.py
Moves approved files, never overwrites, never deletes, logs every run for undo
Web app
slothsort/app.py, static/index.html
FastAPI server and a single page that streams the plan live
Making a 3B model reliable
Small models can drift, so SlothSort keeps them on a short leash:
Structured output. Ollama's format option forces the reply to match a JSON schema.
Folder is an enum. The model can only choose from a fixed list of folders (plus folders that already exist), so it cannot invent Stuff2/.
Temperature 0. The same file gets the same suggestion every time.
Skip the model when it can't help. A .mov or .dmg has no readable content, so a simple rule sorts it instantly.
Two small models instead of one big one. moondream turns a screenshot into a sentence, then qwen2.5:3b makes the decision. Both fit in 8 GB of RAM.
Safety
Nothing moves until you click Move files.
Files are only moved, never deleted, and never overwritten (Report (2).pdf).
Only files sitting directly in the chosen folder can be moved.
Every run is saved in data/history/ and can be undone from the page.
The server only listens on 127.0.0.1, and API calls need a custom header so other websites can't trigger moves.
Run it
Needs Python 3.10+ and Ollama.
1. Get the models (one time, ~3.5 GB)
ollama serve # keep this running in its own tab
ollama pull qwen2.5:3b
ollama pull moondream
2. Install and start SlothSort
git clone https://github.com/Amitrawal1/SlothSort.git
cd SlothSort
pip install -r requirements.txt
python3 demo/make_messy_folder.py # optional: a fake messy folder to play with
python3 -m slothsort.app # open http://127.0.0.1:8000
Command line
python3 -m slothsort.cli plan demo/messy # show the plan only
python3 -m slothsort.cli apply demo/messy # show the plan, ask, then move
python3 -m slothsort.cli runs # list past runs
python3 -m slothsort.cli undo # put files back
Swap the models
Any Ollama model works. Bigger models give better names; smaller ones are faster.
SLOTHSORT_TEXT_MODEL=llama3.2:3b SLOTHSORT_VISION_MODEL=qwen2.5vl:3b python3 -m slothsort.app
You can also edit the folder list in slothsort/config.py.
Project layout
SlothSort/
├── slothsort/
│ ├── config.py settings, models, folder list
│ ├── scanner.py read files
│ ├── brain.py talk to Ollama
│ ├── planner.py build the plan (+ cache)
│ ├── mover.py move + undo
│ ├── app.py web server
│ └── cli.py command line
├── static/index.html the web page
├── demo/make_messy_folder.py
└── requirements.txt
License
MIT
來源:DEV Community · dev.to