Hi folks,
I have been a listener for over a decade and just now decided to sign up. I have somethig to share - most likely I’m not the first person to ever do this … but maybe someone finds use.
I now use a local model LLM (Mistral) to rename my PDFs. But let’s start at the beginning.
Like many others, I receive a lot of PDFs (digitally and scanned) and have a desire to store, organize and archive them.
My current setup i:
iPhone / iPad with SwiftScan for scanning
mostly gmail for email
work laptop (Win11), personal laptop (linux mint)
OneDrive Personal for archiving & storage
headless M2 Mac Mini
Hazel, of course
My preferred naming convention is
YYYY-MM-DD gist of the document 123 EUR.pdf
as most of my documents are invoices. Esp. for tax purposes, I like having the amount in the filename (although, of course, this is also in the content / text layer).
I use a files-and-folders structure (synced through OneDrive). I tried DevonThink and Paperless-ngx … but honestly, I love the simplicity and cross-platformness of a good old files & folders setup. Yes, that’s a bit 1990’s … but so am I
My challenge had been:
I can get Hazel to rename my PDF so that it starts with YYYY-MM-DD … but how can I get the “gist” of the document into the file name?
Here’s what AI (LLMs in particular) are very good at.
So I started to use ChatGPT - or rather Open AI APIs - to send the text of the PDF into the model, extract the date, “gist”, and Euro amount and use this to rename the file … before Hazel cotinues to do its thing.
I achieved this with paid API tokens from Open AI and a python script. I cannot code Python, but ChatGPT can. So Chatty-G wrote the script for me … and it works.
The result was awesome.
Two problems with this:
ChatGPT API calls are expensive. Multiple cents per document quickly add up
Do I really want to send all my PDFs to Open AI servers?
So the solution is a locally run LLM. In my case Mistral running in LM Studio on the M2 Mac Mini. The results are a bit worse than ChatGPT 5 … but still nice.
So this is the flow:
Hazel watches my action folder
OCR script in case the PDF does not have a text layer
Feed PDF text to my local LLM
LLM extracts timestamp, “gist” and EUR amount and renames the file accordingly
Very cool setup! I use Claude connected to Google Drive (with Zapier) and this creates a great LLM and file processing chat interface where I can organize and process documents. I don’t use if for automations, but rather for prompting Claude to process PDF files, but Zapier can have triggers when a new file is added like Hazel.
Drive integration is included in the monthly Claude Pro subscription so no need to use expensive API access or to tinker with local scripting, but Zapier is an extra cost if you need the advanced functionality (like performing an action on new files). I’m not sure if OneDrive is supported, maybe through Zapier.
I was a bit scared at first to be honest - as I really don’t have any relevant coding experience. Without ChatGPT or similar coding assistant I clearly would not have been able to do it.
Running a local LLM sounds much scarier than it is. Especially with LM Studio (I’m sure there are alternatives), I found this to be surprisingly easy. I would have loved to use gpt-oss, but my project startet a week before oss was announced and the Mac Mini I have to run the model is “only” a M2 with 8GB Ram. (I bought this one used just to run Hazel, before I considered running a model locally).
Anyway - Mistral 7b was recommended by my lovely AI assistant - and it runs just fine on the M2 8GB.
Installation was truly just installing LM Studio, selecting the desired model and hitting install/run.
The python script that taps into the local model was (sorry if I am repeating myself) completely written by the assistant.
If anyone is interested to do this as a fun and also useful experiement: don’t be scared
btw, as zapier was mentioned by @Rob_Polding :
I use zapier to extract PFD attachments from gmail and store them in google drive; Hazel moves the PDF from google drive to OneDrive… As the OneDrive zapier integration apparently does not work with M365 Home (only Pro and Enterprise). At least at the time of posting this.
Rob, are you in any way concerned feeding your PDFs through Claude? Or are you not using it for “crown jewels”? I was getting concerned feeding medical files, paychecks, bank statements etc. through an external service. Then again, for me everything ends up in OneDrive anyways.
One of the reasons I choose Claude is their data protection policy - Is my data used for model training? | Anthropic Privacy Center. They do not train on anything you upload unless you specifically send it to be processed through their feedback channels. This is the opposite of ChatGPT who train on data by default unless you specifically opt out.
I don’t upload GDPR-sensitive data (I live in the EU), e.g. as a university vice dean I never upload personal details of students.