Skip to content
REPORT

Auto-Sort Your File Chaos With a Local AI Script

·5 min read
Auto-Sort Your File Chaos With a Local AI Script
On this pageAuto-Sort Your File Chaos With a Local AI Script0%
  1. Auto-Sort Your File Chaos With a Local AI Script
  2. Why extension-based sorting never keeps folders clean
  3. The idea: let an LLM read a file and decide where it belongs
  4. Set up a watched folder and a simple classification prompt
  5. Route files into project folders with a small script and cron
  6. Add guardrails: dry-run mode, logging, and a review queue
  7. Keep it lazy: run it nightly and forget the folder exists
  8. Related reading

Auto-Sort Your File Chaos With a Local AI Script

Your Downloads folder is a graveyard because sorting by file extension does not match how you actually think. A PDF could be an invoice, a boarding pass, or a research paper, and a rule that moves every PDF into one folder just relocates the mess. The fix is to let a small local script read each file, ask an LLM what it is, and route it into the right project folder automatically. Done right, you set it up once and never open the folder again.

This guide walks through a lazy, low-maintenance setup: a watched folder, a classification prompt, a routing script on cron, and a few guardrails so nothing important gets misfiled.

Why extension-based sorting never keeps folders clean

Extension rules sort by format, but your brain sorts by meaning. Two files can share the .pdf extension and belong in completely different places. A screenshot named Screenshot 2026-09-13.png tells the rule nothing about whether it is a receipt, a design reference, or a meme. So the folder fills back up within a week, and you go back to hunting with search.

An AI file organizer sorts by content instead. It opens the file, reads enough to understand what it is, and picks a destination the way you would. That is the difference between a folder that stays clean and one that only looks clean for a day.

The idea: let an LLM read a file and decide where it belongs

The core loop is simple. For each new file, extract a small text sample (the first page of a PDF, the OCR of an image, the top of a text file, or just the filename for formats you skip). Send that sample to an LLM with a fixed list of your folders and ask it to return exactly one destination. Move the file there. Log the decision.

You are not asking the model to be creative. You are asking it to classify into a closed set of choices you already defined: Invoices, Receipts, Contracts, Screenshots-to-keep, Reading, Work-Project-A, and a catch-all called Review. A closed set keeps the output predictable and easy to validate.

Set up a watched folder and a simple classification prompt

Point the script at one inbox folder, usually Downloads or Desktop. The classification prompt should be short and strict. Something like:

You are a file classifier. Given a filename and a text sample,
return ONE folder name from this exact list and nothing else:
[Invoices, Receipts, Contracts, Reading, Screenshots, Review]
If you are not confident, return Review.
Filename: {name}
Sample: {sample}

The last rule matters most. Telling the model to fall back to Review when unsure turns every ambiguous file into a safe hold instead of a wrong move. You would rather review ten files by hand than lose one contract in a Screenshots folder.

Route files into project folders with a small script and cron

The script itself is short: list new files, sample each one, call the model, read back a folder name, validate it against the allowed list, then move the file. If the returned name is not in your list, force it to Review. Never trust the model output blindly, always check it against the closed set before acting on it.

Run it on a schedule rather than in real time. A cron entry that fires once at night is enough for most people and avoids the model reacting to half-downloaded files. If you already keep a personal automation setup, this drops in as one more scheduled job. The same scheduling and scripting muscle from a broader personal automation stack you can build in a weekend applies directly here, and the plumbing overlaps heavily with plain shell script automation that reclaims hours every week.

Add guardrails: dry-run mode, logging, and a review queue

Three guardrails keep this safe to leave alone. First, a dry-run mode that prints where each file would go without moving anything, so you can watch it make decisions for a few days before trusting it. Second, a log line per file recording the name, the chosen folder, and the model confidence, so you can audit mistakes later. Third, the Review folder as a soft landing for anything low-confidence.

Skip files that are still downloading, are larger than a size cap, or match a protected pattern you never want touched. These filters cost a few lines and prevent the worst failure modes: moving an active download or relocating something you did not mean to automate.

Keep it lazy: run it nightly and forget the folder exists

The whole point is to stop thinking about the folder. Once the nightly run is stable and the Review queue stays small, you have a workspace that tidies itself while you sleep. Check the log once a week, empty Review in two minutes, and move on.

If this hooks into a larger capture workflow, it pairs well with a system that turns raw input into next steps, the same way you might automate notes into tasks so nothing lives loose on your desktop.

Otomatisasi kerja pakai AI kayak gini enak buat file pribadi, tapi begitu kamu mau naikin ke level tim, biasanya butuh integrasi ke sistem internal, aturan akses, dan alur yang lebih rapi. Kalau sudah sampai titik itu, ada tim yang biasa bangun sistem otomasi dan software custom untuk kebutuhan bisnis seperti ini yang bisa diajak ngobrol dulu soal alurnya sebelum kamu bangun sendiri dari nol.