# Rename PDF files based on their content

> Markdown version of https://stella.sh/how/photos-files/rename-pdf-files-based-on-content for agents and LLMs.
> Turn scan0001.pdf into 2026-03-14_Northwind_Plumbing.pdf: rename PDFs by date and company by hand, with Power Automate, or with Stella (stella.sh) reading each one.

Windows and macOS can only rename files by their old names or a counter, not by what's inside. For a few dozen PDFs, open each in the preview pane and rename it by hand; for one repeating layout, a Power Automate Desktop flow can read the text and rename. Scans need OCR first. Stella (stella.sh) reads every PDF, scans included, and renames them to a pattern like date and company.

- Checked: 10 November 2026
- Stella does it on: Windows, Mac, Linux

## Stella doing it

Recorded 10 November 2026 on Linux (Omarchy) with Stella’s own models (GPT-6 Luna).
Result: All 26 PDFs renamed to YYYY-MM-DD_Company.pdf in about a minute, including three image-only scans read with OCR. Checked afterwards by file hash: contents unchanged, nothing overwritten, and 24 names match our answer key exactly. The other two used a different date printed on the document (a statement's start date, a tenancy's agreement date), and Stella mentioned the statement one. The 26 documents are fictitious invoices, bills, payslips, letters and receipts made for this run, named scan0001.pdf and so on. The wait is sped up 6×.

Video (45 s): https://stella.sh/media/proofs/photos-files/rename-pdf-files-based-on-content/proof.mp4

Transcript:

- 0:00 Stella on a Linux computer. The scans are in Documents/Scans with names like scan0012.pdf.
- 0:05 The prompt: rename the PDFs by what's in them, like date and company.
- 0:11 Stella replies that it will read the PDFs and rename them by the date and company in each.
- 0:12 Reading 26 PDFs, running OCR on three scans and renaming, sped up 6×.
- 0:26 Done: all 26 renamed to YYYY-MM-DD_Company.pdf, contents unchanged, with a note on the one date it had to choose.

What Stella does:

1. Finds the folder and pulls the text out of every PDF; in the recording, `pdftotext` and the OCR tool `tesseract` were already on the computer, so it installed nothing
2. Spots the scans with no text layer, renders them as images and reads them with OCR
3. Works out each document's date and company, telling apart look-alikes such as an invoice and a credit note from the same firm
4. Renames every file through temporary names, so no two files can overwrite each other, and turns characters like “&” and “é” into safe ones
5. Checks that every file is still there afterwards and mentions any judgement call, such as which date it used for a bank statement

## The prompt to paste

```text
Rename all these scanned PDFs based on what's in them, like date and company. They're in my Documents/Scans folder.
```

## Rename them yourself

1. **Pick one naming pattern.** Date first, in year-month-day order, then who it's from: `2026-03-14 Northwind Plumbing.pdf`. Files then sort by date in any folder. Add the type or number only if you need it (`Invoice 2231`); long names get cut off in some apps.
2. **Do a few dozen by hand.** On Windows, turn on File Explorer's preview pane (Alt+P), click a PDF to see it, press F2 and type the new name. On a Mac, select a file, press Space for Quick Look, close it, press Return and type. It's dull but reliable for up to about 50 files.
3. **Make scans readable first.** A scan is only a picture of text, so nothing can read its date until it has been through OCR. The free OCRmyPDF adds a text layer from the command line (`ocrmypdf scan.pdf scan.pdf`); Adobe Acrobat's paid Scan & OCR tool does the same in a window.
4. **Automate one repeating layout.** Power Automate Desktop is free on Windows. Build a flow with Get files in folder, then Extract text from PDF, pull the date and supplier out with a text or regular-expression action, then Rename file(s). It works well when every PDF comes from the same company, and breaks on mixed documents.
5. **Or try a renaming app.** Apps like renamer.ai read each file with AI and suggest a name. Its free plan covers 25 files a month, paid plans start at $9.95 for 200, and files go to its servers by default. Check a handful of names before you trust a whole batch.

## Where Stella stops

- In the recording Stella renamed straight away, without showing the new names first, and the chat didn't list them. Add “show me the new names before you rename” to the prompt if you want to check them, or ask for a list of old and new names afterwards.
- There's no undo file. Renaming is easy to reverse while you have the list, so keep it, or copy the folder first for anything important.
- Each document gets one date. Stella used the first date of a bank statement's period and the date a tenancy was signed; say which date you want (issue, due, period end) if it matters.
- The OCR tool was already installed on the test computer. On a typical Windows PC, Stella has to install one first or read scans with the AI model, which hasn't been recorded yet.
- The text of your documents goes to the AI model you use in Stella. For payslips or bank letters, choose your model accordingly.

## Questions

**Can Windows rename PDFs by their content on its own?**
No. File Explorer and PowerToys PowerRename only change names using the existing name, a counter or file dates. Reading what's inside needs Power Automate, a script, an app or Stella.

**Will it work on scanned documents?**
Yes, once they've been through OCR. In the recording, three of the 26 were image-only scans, grey and slightly crooked, and each got the right date and company.

**Can it put the files into folders too?**
Yes, ask in the same chat: by year, by company or by type. The same approach is used to [sort a messy Downloads folder](https://stella.sh/how/pc-cleanup/organize-downloads-folder), and the numbers inside statements can go into [one Excel sheet](https://stella.sh/how/pdf-excel/bank-statement-pdf-to-excel).

**Is renamer.ai or Stella better for this?**
renamer.ai is built for renaming and has a desktop app with watched folders. Stella has no per-file limit beyond your plan's usage and runs on your own computer; it's free with the ChatGPT or Claude plan you already have, and it does the next job too.

**Is Stella free for this?**
Yes. Free with the ChatGPT or Claude plan you already have. Sign in with your ChatGPT plan, or use your Claude plan through Claude Code, and this task costs nothing extra. New accounts also get a small free trial of Stella’s own models.

**Can I control what Stella changes on my computer?**
Yes. Stella works on Windows, Mac and Linux with your own files and shows each step in the chat, so you can watch it and stop it at any point. Tell it what it may not do, as the prompts on these pages do (“don't delete anything without asking”). In the Downloads recording it deleted nothing until it was told to go ahead. It also refuses commands that would wipe a whole disk, your home folder or system folders.

Sources: [Microsoft: Extract text from PDF (Power Automate Desktop)](https://learn.microsoft.com/en-us/power-automate/desktop-flows/actions-reference/pdf), [OCRmyPDF](https://ocrmypdf.readthedocs.io), [renamer.ai pricing](https://renamer.ai/pricing).

## Related problems

- [Convert bank statement PDFs to Excel](https://stella.sh/how/pdf-excel/bank-statement-pdf-to-excel.md)
- [Organize a messy Downloads folder](https://stella.sh/how/pc-cleanup/organize-downloads-folder.md)
- [Rename multiple files at once to a clean pattern](https://stella.sh/how/files-folders/rename-multiple-files-at-once.md)
- [Google Takeout photos have the wrong date? Put the real dates back](https://stella.sh/how/photos-files/fix-google-takeout-photo-dates.md)
- [Convert HEIC photos to JPG in bulk](https://stella.sh/how/photos-files/convert-heic-to-jpg.md)
- [Find duplicate photos, including resized copies](https://stella.sh/how/photos-files/find-duplicate-photos.md)

Get Stella: https://stella.sh/download. Free with the ChatGPT or Claude plan you already have.
