SlothSort: a Downloads tidier that runs Gemma on my laptop so I don't have to
Description and use
SlothSort sorts loose files in ~/Downloads into sensible subfolders: obvious files handled by instant extension rules, ambiguous files decided by Gemma 4 running locally via Ollama. It is a dry run by default, never deletes or overwrites, writes an undo log per run, and restricts the model to a fixed list of allowed folders.
Problem
Loose files in a Downloads folder (124 mixed files: lecture PDFs, receipts, installers, screenshots) need sorting into sensible subfolders, but the user is too lazy to sort them manually.
Outcome
SlothSort sorts loose files in ~/Downloads into sensible subfolders: obvious files handled by instant extension rules, ambiguous files decided by Gemma 4 running locally via Ollama. It is a dry run by default, never deletes or overwrites, writes an undo log per run, and restricts the model to a fixed list of allowed folders.
Workflow
- Run slothsort plan to see every move without touching anything (dry run by default).
- Obvious files (.png, .zip, .mp3) are sorted by instant rules.
- Ambiguous files (e.g., PDF that could be lecture notes or receipt) are sent to Gemma 4 (gemma4:e2b) running via Ollama on localhost.
- The model outputs a JSON schema with an enum of allowed folders; output is re-validated in code so wrong answers are rejected and files land in 'Other'.
- Apply moves with slothsort apply; every run writes an undo log to .slothsort/.
- Use slothsort undo to put everything back if needed.
- Change model with --model gemma4:e4b flag if desired.
- Tests run 7 pytest tests using fake classifiers and temp folders; they never need Ollama.
- Zero dependencies: ~90-line Ollama client using only Python standard library.
- Never deletes or overwrites; name clashes become 'name (2).ext'.
- Model can only choose from a fixed list of folders.
Evidence
My Downloads folder had 124 loose files: lecture PDFs, receipts, installers and screenshots, all mixed together.
SlothSort does it for me. Obvious files (.png, .zip, .mp3) are sorted by instant rules. The ambiguous ones, like a PDF that could be lecture notes or a receipt, go to Gemma running on my own machine. It files them under Study, Work, Personal or Receipts.
It is a dry run by default. It never deletes or overwrites. Every run writes an undo log. The model can only choose from a fixed list of folders.
Model: Gemma 4 (gemma4:e2b) served by Ollama on localhost.
Structured output: I pass a JSON schema with an enum of allowed folders. I also re-validate the answer in code, so a wrong or made-up folder gets rejected and the file lands in 'Other'.
Rules first, model second: extension rules handle the obvious files instantly, which keeps it fast and cheap.
- Record date: 2026-10-21T12:41:39.291Z