AI Tool · Live
Auto Archiver
A Python script on my Synology NAS that automatically sorts business documents based on a predefined folder structure, renames them with a date prefix, and forwards invoices straight to the accountant.
Background
A PC crash, two days of work lost.
In early 2024 my work computer crashed and I lost part of my local working folder. Not everything, but enough to spend two days reconstructing what was there. Something painful stood out in the process: a large part of what I'd lost were documents I should have archived on the NAS long ago. Invoices I'd never forwarded, contracts that were in two places, screenshots left hanging in a temporary folder.
The problem wasn't that the NAS wasn't there. The problem was that archiving manually was too much work. The same ritual every time: open file, see what it is, find the right folder, rename with date, move, possibly forward. Nobody does that consistently. So I didn't either.
The solution had to be one action: I drag something into an inbox folder and the rest happens by itself. No clicking, no deciding, no remembering.
How it works
One inbox folder as the gateway.
The user decides nothing. The script reads the desired destination from the name of the subfolder where a file is dropped, adds a date prefix and places it in the right spot.
-
Open the inbox
On the NAS there's a shared folder with the structure you want in your archive. A drag-and-drop window with subfolders: invoices, contracts, bank statements, tax, personal, and so on.
-
Drop the file in the subfolder
Work from your laptop, phone or mailbox: drag the file to the right subfolder within the inbox. The choice of subfolder is the classification. No tags, no forms.
-
Script detects new files
A Python script runs every five minutes on the NAS. It scans all subfolders for new files and processes them in order of arrival.
-
Rename with date prefix
Each file gets a prefix in YYYY-MM-DD format based on the file creation date or the first readable date in the document. This way files are chronologically sortable without having to open them.
-
Forward if invoice
Files from the 'invoices' subfolder are emailed straight to the accountant as an attachment (Yuki mailbox). The accountant books them in. No extra action.
Technology
What's under the hood.
The script runs on Python 3 on a Synology DSM server. A cron job runs it every five minutes, with a lockfile to prevent duplicate runs if a batch isn't finished yet.
For the mail function, SMTP is used with a dedicated mail server. The subfolder name triggers the send profile. A subfolder 'invoices-yuki' sends to the Yuki admin inbox, a subfolder 'personal-archive' doesn't. Configuration sits in a YAML file next to the script, easy to adjust without touching the code.
No external services, no cloud. It runs entirely on private infrastructure. No subscriptions, no vendor lock-in. The script is about 200 lines of Python and uses only standard libraries.
Roadmap
What's planned.
The current version has been running in production since late 2024 and has processed thousands of documents without me having to think about it any more. Still, there are a few next steps on the planning.
Phase 6 — AI classification
At the moment, the user decides themselves which subfolder something goes into. The next step is for an AI model to suggest that itself. Drag a file into one inbox folder, the script reads the content (OCR for PDFs and images), classifies it, and suggests a target folder. The user confirms (one click) or corrects.
Phase 7 — Multi-user
For my wife (Adeline Fotografie) a separate profile would be handy, with different subfolders and a different accountant. The current version is single-user. Multi-user will be a refactor of the config layer.
Phase 8 — Notifications
There's currently no feedback to the user on processing. A simple daily summary by email ("processed today: 7 invoices, 3 bank statements, 1 contract") would be enough. No push notifications, no dashboard. Keep it simple.
See it in action
Visualisation of the archiving process.
A visual representation of how documents flow through the tool, from inbox to archive. Opens in a new tab.
Open de visualisatie →