# Rename PDFs by Content - Name Files from Dates & Numbers

> Batch rename PDFs by content: put dates, invoice or order numbers, emails, totals, titles or labelled text into a name pattern; preview clashes.

- URL: https://qilingtools.com/en/pdf/rename
- Category: PDF Tools (https://qilingtools.com/en/pdf)
- Tags: [PDF](https://qilingtools.com/en/tags/pdf), [Documents](https://qilingtools.com/en/tags/document), [Productivity](https://qilingtools.com/en/tags/office)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

PDFs from scanners, banks and online shops tend to arrive as scan0001.pdf or download (3).pdf, and opening each one to rename it is tedious. This tool reads the text of the first pages of every PDF (optionally running OCR on scans without a text layer) plus its document properties, extracts the fields you define and renames the files with a pattern. Fields come from four sources: presets (the first date in formats such as 2024-03-05, 03/05/2024, 5 Mar 2024, March 5, 2024 or 2024年3月5日; invoice number; order number; email; total amount; the largest line as the title; the first line), a custom regular expression (group 1 if there is a capture group, first or last match), text next to a label (enter a label such as “Contract No.” or “Customer” and it takes the value to the right or just below, optionally matching a format), and document properties (title, author, subject, keywords, creation date). Combine them in a pattern with {field}, add {n} or {n:3} for a counter, {name} for the original name and {pages} for the page count; empty fields are dropped together with the separator after them, or replaced with text you choose. The preview lists every extracted value and the new name, which you can edit; duplicates, invalid characters, reserved names and over-long names are flagged, and duplicates can get (2), (3) automatically. Then download the renamed PDFs as a ZIP — or, for many large files, just a bash or PowerShell script that renames them in place (swaps go through temporary names so nothing is overwritten) plus a mapping CSV. Everything runs locally; files are never uploaded.

## How to use

1. Select or drop several PDFs, choose how many pages to read and tick OCR for scans
2. Add fields — presets, regex, text next to a label or document properties — and write a file name pattern
3. Check the new names and any clashes in the preview, then download the ZIP or a rename script

## Features

- Extracts fields from the first N pages and document properties
- Presets: date, invoice no., order no., email, amount, title, first line
- Custom regex with capture groups and label-proximity rules
- Optional local OCR for scans without a text layer
- Patterns with padded counters, original name and page count
- Detects duplicates, invalid and reserved names; auto-numbering
- Download a renamed ZIP or a bash / PowerShell script to rename in place
- Runs locally, never uploaded

## FAQ

### How does “text next to a label” work?

Enter a label that always appears in your documents, such as “Contract No.”, “Customer” or “Invoice No.”. The tool finds it and takes the text after a colon in the same piece of text, otherwise the nearest text to the right on the same line, and — if you allow it — the line just below. You can also give a value format (a regex such as [A-Z]{2}-\d+) so only matching values are accepted.

### Which part of a regex match is used?

If the pattern has capture groups, the first non-empty group is used; otherwise the whole match. For example Order\s*#?(\d+) keeps just the digits. You can pick the first or last match, matching ignores case by default, and an invalid pattern is flagged next to the field.

### Does it work with scanned PDFs?

Yes — tick “OCR pages that have no text layer” and the page text is recognised locally with a Chinese/English OCR model before fields are extracted. The first run downloads a ~15 MB model and each page takes a few seconds. OCR can misread characters, so check the preview before renaming.

### Is the rename script safe?

It only contains mv (bash) or Rename-Item (PowerShell) commands with every name properly quoted. The bash version uses mv -n so it never overwrites an existing file, and when new and old names collide it renames through temporary names first. Run it inside the folder that holds the PDFs; files with problem names are left out.

## Related tools

- [Merge PDF](https://qilingtools.com/en/pdf/merge): Free online PDF merger: combine several PDF files into one in the order you choose, with reordering. Processed locally in your browser, no upload, no sign-up.
- [Split / Extract PDF](https://qilingtools.com/en/pdf/split): Free online PDF splitter: extract a page range into a new PDF, or split every page into its own file and download them as a ZIP. Processed locally.
- [Rotate PDF](https://qilingtools.com/en/pdf/rotate): Free online PDF rotator: rotate all or selected pages by 90°, 180° or 270° to fix scanned documents. Processed locally, no upload.
- [PDF to Image](https://qilingtools.com/en/pdf/to-image): Free online PDF to image converter: render every page as a high-resolution JPG or PNG at 72/150/300 DPI, download all as a ZIP. Processed locally, no upload.
- [Image to PDF](https://qilingtools.com/en/pdf/from-image): Free online image to PDF converter: combine JPG, PNG and WebP images into one PDF in order, with A4 or image-sized pages. Processed locally, no upload.
- [Compress PDF](https://qilingtools.com/en/pdf/compress): Free online PDF compressor: re-render pages with compressed images to shrink scanned and image-heavy PDFs, with adjustable quality. Processed locally.
- [Watermark PDF](https://qilingtools.com/en/pdf/watermark): Free online PDF watermark tool: add text watermarks to every page, tiled or centred, with opacity and angle controls. Any language, processed locally.
- [Delete PDF Pages](https://qilingtools.com/en/pdf/delete): Free online tool to delete PDF pages: remove pages by number or range and keep the rest, then download. Processed locally, no upload.
