sloth-tidy:以本機 AI 模型整理檔案的命令列工具
sloth-tidy
sloth-tidy 是一款命令列工具,透過 Ollama 在本機呼叫開放權重 AI 模型,辨識檔案並分類到資料夾、改成易讀檔名,預設使用 llama3.2:3b。工具預設先試行整理,並設有避免覆寫的重新命名機制和復原記錄;毋須帳戶、API 金鑰或逐次付費。
Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥
This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady
What I Built
sloth-tidy is a tiny command-line tool that cleans up a messy folder so you don't have to. It reads each file's name (and the start of its text, if it's a text file), asks a local AI model what it is, then sorts it into a folder like Documents or Archives and gives it a readable name. Scan 001.txt becomes Documents/invoice-march-electricity.txt.
It's built for the "I'll sort my Downloads folder this weekend" crowd, which is to say, me.
Code
https://github.com/Anirban846/sloth-tidy
How I Built It
- Model: any open-weight model served locally by Ollama. I defaulted to
llama3.2:3bbecause it's small enough for a laptop. - Approach: one file per request, with the model forced to return JSON (
format: json). I validate the reply: unknown categories becomeOtherand names are slugified, so a bad answer can't produce a bad path. - Safety, because lazy people don't check: dry run by default, a collision-proof renamer that never overwrites, and an undo log so
--undoputs everything back. - Dependencies: none. Python's standard library talks to Ollama's local HTTP API.
- Fallback: if the model isn't running, it sorts by file extension instead of crashing.
Why Does Open Innovation Matter?
A file tidier reads your files. Receipts, scans, half-finished documents. Sending those to a closed API just to rename them felt wrong, so with an open-weight model the whole thing runs on my own machine with no account, no key, and no per-call cost. Set it up once and it's free forever.
It also means I can swap models with one flag (--model) as better small ones appear, and fix the behavior with a prompt edit instead of waiting on a vendor.
來源:DEV Community · dev.to