sturdybits

Guides / Split by Name

How to rename PDF files based on their content

30 November 2026

To rename PDF files based on their content, something has to open each file, find the right text, such as a person's name or an invoice number, and use it as the new file name. For a few files, do it by hand. For a folder of them, a Power Automate flow on Windows or a short Python script can do it, as long as the PDFs contain real text and the layout stays the same.

Why it's harder than it looks

Batch renaming doesn't help on its own. Finder's Rename command on a Mac, for example, replaces text, adds text or numbers files, but it can't look inside them.

1. Rename by hand

Good for: a few files.

It's free, but slow, and it's easy to mistype a name or give a file the wrong person's name. Check each one.

2. Build a flow in Power Automate for desktop

Good for: Windows users happy to set up a small automation.

Power Automate for desktop is Microsoft's automation app, free for Windows 11 users. A flow for this job uses four kinds of action:

  1. Get files in folder to list the PDFs.
  2. A loop that runs Extract text from PDF on the first page of each file.
  3. Text actions to pick out the name, such as the text after "Employee name".
  4. Rename file(s) with the Set new name scheme.

Leave If file exists in Rename file(s) set to Do nothing, the default, so a repeated name can't replace another file. Microsoft's reference pages list the PDF actions and file actions. For scanned pages you'd need its separate OCR actions too.

3. Write a short Python script

Good for: people comfortable running code.

With Python and the free pypdf library (pip install pypdf), this script renames every PDF in a folder called payslips after the text that follows "Employee name" on its first page:

import re
from pathlib import Path
from pypdf import PdfReader

for path in sorted(Path("payslips").glob("*.pdf")):
    text = PdfReader(path).pages[0].extract_text()
    found = re.search(r"Employee name:?\s*(.+)", text)
    target = path.with_name(found.group(1).strip() + ".pdf") if found else None
    if target and not target.exists():
        path.rename(target)
    else:
        print("Check by hand:", path.name)

Change the folder name and the pattern to suit your files. The pattern copes with the name on the same line as the label or on the line after it. Any file where it finds no name, or where the new name is already taken, is listed for you to deal with by hand.

That last check matters. Without it, Python stops with an error on Windows, and on a Mac quietly replaces the other file. The script doesn't remove characters Windows won't accept, and it can't read scanned pages, as pypdf doesn't do OCR.

4. Document-processing services

Good for: large volumes of mixed documents, if uploading them is acceptable.

Some online services and AI apps read documents and rename them for you. Many work by uploading your files to their servers, which matters when the PDFs hold personal details, such as payslips or medical letters. Before sending them anything, check who runs the service, what it keeps and for how long.

Name the files as you split them

Often the files that need renaming came from splitting one big PDF, such as a payroll run, a batch of invoices or a mail merge. Naming them during the split saves the renaming step.

That's what Split by Name does. Drop in the PDF and click the name or number on the page. It starts a new file wherever that changes, keeps a second page with the page before, and names each file from the page, such as "Asha Patel - November 2026.pdf". You can combine several values, such as a name and a date. Characters that file names can't contain are replaced, and repeated names get (2), (3) and so on, so nothing is overwritten. The .zip file includes an index of which pages went where.

It works on one PDF at a time. If you already have a folder of separate files, you can combine them into one PDF first (Preview on a Mac can) and split it again by name. It needs real text, so scanned pages need OCR first.

It runs in your browser and the files never leave your computer. The free version makes up to 10 files at a time; Pro is £29 once and makes any number. You can try it with sample payslips, or read how to split a PDF of payslips into one file per employee.

Quick answers

Can Windows rename PDFs from their content by itself? Not from File Explorer. Power Automate for desktop, free for Windows 11 users, can do it with a flow that extracts each file's text and renames it.

Can Acrobat rename PDFs based on their content? Not on its own. Its Split command names files after bookmarks or with a label added. Naming them from the text on the page takes a script or a plug-in.

Why does my script find no text in some PDFs? They're probably scanned pages, which are pictures of text. Run OCR on them first, then try again.