Sloth Sort:本機 AI 整理 Downloads 資料夾,省去手動分類
Sloth Sort: I let a local AI clean my Downloads folder so I never have to
Yash Dharme 開發了 Sloth Sort,利用本機 Gemma 3 1B 整理 Downloads 資料夾,先列出計劃供用戶檢視,再由用戶執行或復原。在 19 個虛構檔案的測試中,工具於 19 秒內完成計劃,其中 9 份文件交由 Gemma 處理;執行後可將檔案全部復原。模型一次下載約 860 MB,之後可離線運作,無需 API key。
This is a submission for the Hacktoberfest Open-Source AI Challenge: Week 3 — Slow and Steady.
What I Built
Everyone has a Downloads folder like this:
download.pdf download (1).pdf scan0003.pdf
Document.pdf e-ticket_8F3K2.pdf statement_092026.pdf
untitled.md notes.txt export.csv
Screenshot from 2026-10-02 21-14-07.png project-final-FINAL.zip
code-1.105.0-amd64.deb lecture-recording.mp4 …
Somewhere in there is the bill you need to pay, the internship offer you need to sign, and the flight ticket you'll be frantically searching for at the airport gate. Cleaning it up means opening every download (1).pdf to find out what it is. So nobody does.
Sloth Sort does it for you. It's a small command-line tool:
sloth-sort plan ~/Downloads # look at everything, decide, move nothing
sloth-sort apply ~/Downloads # do exactly what you just reviewed
sloth-sort undo ~/Downloads # put it all back
The interesting part is that it reads your documents and gives them names a human would search for, using Gemma 3 1B running on your own machine.
Demo
This is real output from my test folder of 19 made-up files (the repo has a script that generates the same folder, so you can try it safely):
📁 Documents/Bank & Finance/
statement_092026.pdf → 2026-10 Riverbank Savings Account.pdf ✨
📁 Documents/Bills & Receipts/
download.pdf → 2026-10 Sunrise Telecom Tax Invoice.pdf ✨
export.csv → 2026-10 Groceries & Electricity Bills.csv ✨
📁 Documents/Health/
Document.pdf → Paracetamol Dosage.pdf ✨
📁 Documents/Study/
download (1).pdf → Normalization Database Management Systems.pdf ✨
untitled.md → Paging and Segmentation.md ✨
📁 Documents/Travel/
e-ticket_8F3K2.pdf → Pune to Bengaluru flight ticket.pdf ✨
notes.txt → Goa Trip Essentials.txt ✨
📁 Documents/Work & Career/
scan0003.pdf → Brightleaf Software Internship Offer.pdf ✨
📁 Screenshots/2026-10/
Screenshot from 2026-10-02 21-14-07.png
Screenshot from 2026-10-11 09-02-55.png
…
19 files planned (9 read by Gemma ✨, the rest by type) in 19s. Nothing has moved yet.
Then apply moved all 19, and undo put every one of them back exactly where it was. I checked that by comparing a hash of the file list before and after.
The lazy payoff
- 19 seconds to plan 19 files on a laptop CPU, with no GPU (after the model's one-time download).
- 9 documents read for me, and every one of them landed in the right folder with a name that says what it is.
-
One command to review, one to apply. The alternative is opening nine
download (1).pdf-style files one by one. I'd guess that's 5–10 minutes of clicking for this folder. For a real Downloads folder with a few hundred files, it's the afternoon I've been putting off for two years.
Code
Yash11778
/
sloth-sort
Tidy a messy Downloads folder with an open-weight model (Gemma) that runs on your own machine.
🦥 Sloth Sort
Tidy a messy Downloads folder with an open-weight model that runs on your own machine It reads your documents, files them into sensible folders with names you can actually search for, shows you the plan, and only moves things when you say so. One command undoes it all.
Built for the Hacktoberfest Open-Source AI Challenge, Week 3: Slow and Steady.
$ sloth-sort plan ~/Downloads
📁 Documents/Travel/
e-ticket_8F3K2.pdf → Pune to Bengaluru flight ticket.pdf ✨
📁 Documents/Work & Career/
scan0003.pdf → Brightleaf Software Internship Offer.pdf ✨
📁 Documents/Bills & Receipts/
download.pdf → 2026-10 Sunrise Telecom Tax Invoice.pdf ✨
📁 Screenshots/2026-10/
Screenshot from 2026-10-02 21-14-07.png
...
19 files planned (9 read by Gemma ✨, the rest by type) in 19s. Nothing has moved yet.
$ sloth-sort apply ~/Downloads # do it
$ sloth-sort undo ~/Downloads # changed your mind
How it works
- Obvious files are sorted by…
MIT licensed. About 500 lines of plain Node.js (ES modules), including the demo generator, with no build step.
git clone https://github.com/Yash11778/sloth-sort && cd sloth-sort && npm install
npm run demo # makes a messy folder of made-up files
node bin/sloth-sort.mjs plan demo-downloads
How It Works
every file ──► hidden / half-downloaded / changed in the last 2 min? ──► leave alone
──► image, video, installer, archive, code, font? ──► sort by type (instant)
──► document ──► read the first ~1,500 characters (PDF, Word, text, CSV)
──► clear keywords? ("PNR", "account statement", "prescription")
yes ─► that folder
no ─► Gemma picks one of 8 folders
──► Gemma writes a title, shaped for that folder
──► plan saved to disk ──► you review ──► apply ──► undo log
Lesson 1: the model is the last resort, not the first
Most of a Downloads folder doesn't need AI. A .png named Screenshot from … goes in Screenshots/<month>, and a .deb goes in Installers. So only documents ever reach the model. In the demo, that's 9 of 19 files.
Even for documents, my first version asked Gemma to pick one of eight folders, and it got three of nine wrong: the flight e-ticket went to Bills, the bank statement to Bills, and the internship offer letter to Other. A 1B model choosing among eight similar categories is guessing. But "PNR" or "boarding pass" in a document is not ambiguous, so clear keywords now decide first:
const RULES = [
['travel', /\b(pnr|boarding pass|e-?ticket|itinerary|flight|departure|…)\b/i],
['health', /\b(prescription|diagnosis|lab report|physician|…)/i],
['bank', /\b(account statement|opening balance|ifsc|salary slip|…)\b/i],
['work', /\b(offer letter|internship|resume|appointment letter|…)\b/i],
// …
];
Gemma still decides anything the keywords don't recognise. After this change, all nine landed in the right folder.
Lesson 2: don't show a small model the old name, or any real-looking example
My first title prompt included the filename, and Gemma handed scan0003 and Document straight back. Then I removed the filename and added an example title, "Sunrise Telecom September Bill", and the prescription came back as "Sunrise Telecom Patient Care". A 1B model will happily copy whatever concrete text you put in front of it.
The fix was to give it only the document's contents, plus a shape rather than an example, chosen for the folder it's going to:
const SHAPE = {
bills: '"<company> <month> bill" or "<shop> order receipt"',
travel: '"<airline> <from> to <to> ticket" or "<city> hotel booking"',
work: '"<company> offer letter" or "<name> resume"',
// …
};
That's how e-ticket_8F3K2.pdf became "Pune to Bengaluru flight ticket" instead of "Airline November Bill airline", which is what it produced while every document got the same bill-shaped hint.
Lesson 3: a tool that moves your files has to be boring about safety
-
It plans first and moves nothing. The plan is written to disk, and
applydoes exactly that plan. - It only moves files, inside the one folder. Nothing is deleted or overwritten, and a name clash gets " (2)".
-
It refuses to escape. I edited a plan by hand to move a file to
../../escaped.txt, andapplyrefused:Refusing to touch ../../escaped.txt: outside …. -
Half-finished downloads are left alone (
.crdownload,.part, anything modified in the last 2 minutes). -
undorestores everything and removes only the folders it created, and only if they're empty.
Why Open Matters Here
Your Downloads folder is the most private folder on your computer: bank statements, ID scans, offer letters, prescriptions, tickets with your PNR on them. A tool like this only makes sense if nothing leaves your machine. A hosted model would mean uploading all of it to sort it.
With an open-weight model, that isn't a trade-off:
- It runs locally. Gemma 3 1B runs through Transformers.js and onnxruntime-node, on a normal laptop CPU.
- It works offline. After a one-time ~860 MB download, it never touches the network.
- It's free, forever. No API key and no per-file cost, so running it on 2,000 files costs the same as on 20.
-
The model is swappable. Set
SLOTH_MODELto try a bigger or newer ONNX model.
What's Next
- A watch mode, so new downloads get filed as they arrive. Maximum sloth.
-
Images by content with a small open vision model: receipts, whiteboards and memes are all
.jpg. - Hindi and Marathi documents, which need a bigger multilingual model.
Prize Categories
Best Use of Gemma. Gemma 3 1B is the only model in the project. It runs locally and does both the folder decisions the keywords can't make and every new file name.
Built with AI assistance (Claude Code) for scaffolding, testing and debugging. Every file in the demo is made up; no real documents were used.
來源:DEV Community · dev.to