跳到正文
DEV Community· DHIRAJ BHAVIKATTI·· 2 小時前AI 評分48

Sloth-Sorter:命令列檔案整理工具

Sloth-Sorter: Command Line Tool.

AI 導讀

Sloth-Sorter 是一款開源命令列工具,使用本機小型 AI 模型整理並重新命名 Downloads 資料夾內的檔案,檔案不會離開用戶的電腦。工具預設使用可在 CPU 執行的 Qwen2.5 3B,亦可改用 Llama 3.2 3B;每次移動均可復原,且不會刪除或覆寫檔案。

正文

Cover image for Sloth-Sorter: Command Line Tool.

DHIRAJ BHAVIKATTI

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 Sorter is a command-line tool. It sorts and renames the files in your Downloads folder. A small AI model on your own computer does the work. No file leaves your machine.

Example: bill_oct.pdf becomes Documents/Bills/2026-10_Electricity-Bill.pdf.

Many AI organizers upload your bank statements, IDs, and resumes to a server you do not control. Sloth does not. Anyone with a messy Downloads folder can set it up once and stop sorting by hand.


Demo

$ sloth plan --folder ~/Downloads
Plan: 14 files
  bill_oct.pdf  ->  Documents/Bills/2026-10_Electricity-Bill.pdf
  setup.exe     ->  Installers/setup.exe
2 files need review. Nothing has changed yet.

$ sloth run --folder ~/Downloads --yes
14 files tidied. 2 need review.

$ sloth undo --last 3
Put 3 files back.

Code

github.com/DhirajB05/sloth-sorter


How I Built It

Open-source parts

  • Ollama runs the model on my computer.
  • Qwen2.5 3B is the default model. It runs on CPU. You can swap it for Llama 3.2 3B or another model with one line in sloth.toml.
  • Python tools: watchdog, typer, pydantic, pypdf, python-docx, SQLite.

How it works

  1. Watch the folder for new files.
  2. Wait until the file is fully downloaded (size and time stay the same for 3 seconds).
  3. Read the first 1,500 characters of the file.
  4. Ask the model for a category and a clean name. Ollama must reply in a fixed JSON format. Pydantic checks the reply.
  5. Make sure the new path stays inside the folder.
  6. Move the file. Save the move in a SQLite log.

Fallbacks

If Ollama is off, Sloth sorts by file extension. If the model is not sure, the file goes to Needs Review.

Safety rules

  • Sloth never deletes or overwrites a file. A name clash gets a number: file (2).pdf.
  • Sloth ignores partial downloads (.crdownload, .part, .tmp).
  • Sloth only talks to localhost. A test fails if any other network call happens.
  • Every move can be undone with sloth undo.

Limits

  • The model makes mistakes. Example: [one real wrong result].
  • Sloth does not read images. It uses only the file name.
  • Scanned PDFs have no text, so the model has little to read.

Why Does Open Innovation Matter?

  • Privacy: your files stay on your disk. A closed API needs an upload for each file.
  • Offline: it works with no internet. [I tested with Wi-Fi off: result.]
  • Cost: it costs nothing to run after install. A closed API charges for each call.
  • Swap models: I compared two models by changing one config line. A closed API gives you the model the vendor chooses.
  • Control: I set my own folders and naming rules in a config file.

來源:DEV Community · dev.to