PDF Content Renamer
Rename PDFs based on evidence found inside the document. Prefer accurate, boring filenames over clever summaries, and preserve enough traceability to explain how each name was chosen.
Naming Standard
Use this format unless the user specifies another convention:
YY-MM-DD Name Type Detail.pdf
Rules:
- Start every filename with
YY-MM-DD.
- Use the most relevant date found in the document. If no reliable date is found, use today's date in the user's timezone.
- After the date, use human-readable Title Case words separated by spaces.
- Prefer this order after the date: person/entity or provider name, document type, and useful distinguishing detail.
- Keep names concise: name/provider, document type, subject/account tail, period, location/state, or short distinguishing detail.
- Remove unsafe filesystem characters:
< > : " / \ | ? *, control characters, repeated spaces, and trailing dots.
- Do not overwrite existing files. Add
-v2, -v3, etc. only when needed.
- Preserve the original
.pdf extension.
Examples:
26-06-30 CommBank Bank Statement Everyday 1234.pdf
25-11-14 Jane Smith Driver Licence NSW.pdf
26-02-03 Sydney Clinic Medical Report Blood Test.pdf
26-07-06 Patricio Perpetua Driver License Victoria.pdf
26-07-03 Unknown Document Unclassified.pdf
Date Selection
Pick the date that best identifies the document, not necessarily the first date encountered.
| Document type |
Preferred date |
| Bank or credit card statement |
Statement period end date, then issue date |
| Driver licence or identity document |
Issue date, then expiry date |
| Medical report, invoice, referral, result |
Service/visit/specimen/report date, then issue date |
| Insurance, tax, legal, government notice |
Notice/issue/effective date |
| Receipt or invoice |
Transaction/invoice date |
| Contract or agreement |
Signed/effective date |
| Unknown document |
Most prominent document date, then today's date |
Convert all dates to YY-MM-DD. If the document only gives a month or period, use the period end when clear; otherwise use the first day of the month and mention the uncertainty.
Prerequisites
Install from GitLab npm registry (recommended)
The package is public — no GitLab token required. Point the @singleton-sd scope at the project registry (once per machine or project), in .npmrc:
@singleton-sd:registry=https://gitlab.com/api/v4/projects/singleton-sd%2Fai-plattform%2Ftools%2Fpdf-context/packages/npm/
Then install:
npm install @singleton-sd/ai-plattform-tools-pdf-context
One-off run (no install; .npmrc scope line still required):
npx @singleton-sd/ai-plattform-tools-pdf-context \
--pdf "C:/path/to/document.pdf" \
--max-pages 3
After install, the CLI binary is pdf-context (from node_modules/.bin).
Install from source (development)
git clone git@gitlab.com:singleton-sd/ai-plattform/tools/pdf-context.git
cd pdf-context
yarn install
When working inside the ai-plattform workspace, the tool repo is at tools/pdf-context/.
Workflow
Task progress:
- [ ] Confirm pdf path(s)
- [ ] Install `@singleton-sd/ai-plattform-tools-pdf-context` if not present (see Prerequisites)
- [ ] Run pdf-context for each PDF
- [ ] Route large or scanned PDFs to pdf-to-markdown when needed
- [ ] Classify, pick date, propose filename(s)
- [ ] Present proposals (rename only if user confirms)
Resolve inputs.
- Accept a single PDF, a folder, or a batch list.
- Work from absolute paths.
- For bulk renames, create a manifest with original path, proposed path, inferred date, date evidence, document type, confidence, and notes.
Extract enough content.
- Prefer Node.js tools for all extraction, parsing, manifest generation, and renaming commands.
- Always start with
pdf-context — use the published CLI (do not hand-roll extraction unless the tool fails):
pdf-context \
--pdf "C:/path/to/document.pdf" \
--max-pages 3
If the package is not on PATH, use npx @singleton-sd/ai-plattform-tools-pdf-context.
When developing from source inside ai-plattform:
node tools/pdf-context/extract_context.mjs \
--pdf "C:/path/to/document.pdf" \
--max-pages 3
- Parse the JSON stdout for
page_count, metadata, pages, combined_text, and likely_scanned.
- If
page_count ≤ 3 and likely_scanned is false, use that JSON as the evidence source for classification, date selection, and filename proposals.
- Use
metadata.creation_date / metadata.mod_date (already YY-MM-DD) as date hints, then apply the date selection table using text from pages or combined_text.
- If
page_count > 3, use the documents/pdf-to-markdown skill instead of loading the whole PDF into context.
- If
likely_scanned is true, route through the OCR-capable mode in documents/pdf-to-markdown; do not create ad hoc Python extraction scripts.
- Stop once there is enough evidence for a high-confidence name.
Classify the document.
- Identify the document type from headings, labels, issuer, and repeated terms.
- Prefer specific types such as
bank-statement, driver-licence, medical-report, pathology-result, invoice, receipt, insurance-notice, or tax-notice.
- Use
unknown-document when evidence is weak.
Build the proposed filename.
- Apply the date rules first.
- Use human-readable Title Case words separated by spaces after the date.
- Add person/entity or issuer/provider when visible.
- Add a safe identifier only when useful, such as account last four digits, licence state, patient name, claim number, or document reference.
- Avoid full account numbers, full licence numbers, Medicare numbers, tax file numbers, or other high-risk identifiers.
Verify and rename.
- Present proposed names before renaming unless the user explicitly asked for immediate renaming.
- Use filesystem-safe move/rename commands and avoid overwrites.
- After renaming, report the old path, new path, and any low-confidence decisions.
Confidence Rules
Use high confidence only when the document type and date are both directly supported by text or reliable metadata. Use medium confidence when the type is clear but the best date needed judgment. Use low confidence when the file is scanned poorly, mostly blank, encrypted, or has conflicting document labels.
For low-confidence items:
- Keep
unknown-document or unclassified in the filename.
- Use today's date only when no document date is reliable.
- Do not invent issuers, dates, names, or categories.
- Include a short note explaining what could not be verified.
Reporting Template
PDF rename proposals
1. {original_filename}
Proposed: {YY-MM-DD-name.pdf}
Basis: {document type}, {date source}, {issuer/provider}
Confidence: {high|medium|low}
Notes: {only if needed}
Renamed files:
- {old_path} -> {new_path}
Troubleshooting
| Problem |
Action |
| Package not found / 404 on install |
Add the @singleton-sd scope registry line to .npmrc (see Prerequisites) |
pdf-context not on PATH |
Use npx @singleton-sd/ai-plattform-tools-pdf-context |
likely_scanned: true |
Re-run via documents/pdf-to-markdown with --mode hybrid and OCR |
page_count > 3 |
Use documents/pdf-to-markdown for full extraction |
| Empty or conflicting dates |
Fall back to date selection rules; use today's date only when no document date is reliable |
Additional resources
1---2name: pdf-content-renamer3description: Rename PDF files from their contents using safe, date-prefixed filenames and Node.js-based PDF tooling. Use when the user provides one or more PDFs and wants filenames inferred from document text, such as bank statements, driver licences, medical documents, receipts, notices, contracts, or other personal/business records. For small PDFs (typically 1–3 pages), use `pdf-context` first; for large or scanned PDFs, route through `documents/pdf-to-markdown`.4---56# PDF Content Renamer78Rename PDFs based on evidence found inside the document. Prefer accurate, boring filenames over clever summaries, and preserve enough traceability to explain how each name was chosen.910## Naming Standard1112Use this format unless the user specifies another convention:1314```text15YY-MM-DD Name Type Detail.pdf16```1718Rules:1920- Start every filename with `YY-MM-DD`.21- Use the most relevant date found in the document. If no reliable date is found, use today's date in the user's timezone.22- After the date, use human-readable Title Case words separated by spaces.23- Prefer this order after the date: person/entity or provider name, document type, and useful distinguishing detail.24- Keep names concise: name/provider, document type, subject/account tail, period, location/state, or short distinguishing detail.25- Remove unsafe filesystem characters: `< > : " / \ | ? *`, control characters, repeated spaces, and trailing dots.26- Do not overwrite existing files. Add `-v2`, `-v3`, etc. only when needed.27- Preserve the original `.pdf` extension.2829Examples:3031```text3226-06-30 CommBank Bank Statement Everyday 1234.pdf3325-11-14 Jane Smith Driver Licence NSW.pdf3426-02-03 Sydney Clinic Medical Report Blood Test.pdf3526-07-06 Patricio Perpetua Driver License Victoria.pdf3626-07-03 Unknown Document Unclassified.pdf37```3839## Date Selection4041Pick the date that best identifies the document, not necessarily the first date encountered.4243| Document type | Preferred date |44| ------------- | -------------- |45| Bank or credit card statement | Statement period end date, then issue date |46| Driver licence or identity document | Issue date, then expiry date |47| Medical report, invoice, referral, result | Service/visit/specimen/report date, then issue date |48| Insurance, tax, legal, government notice | Notice/issue/effective date |49| Receipt or invoice | Transaction/invoice date |50| Contract or agreement | Signed/effective date |51| Unknown document | Most prominent document date, then today's date |5253Convert all dates to `YY-MM-DD`. If the document only gives a month or period, use the period end when clear; otherwise use the first day of the month and mention the uncertainty.5455## Prerequisites5657- Node.js 20.19+58- Install [`@singleton-sd/ai-plattform-tools-pdf-context`](https://gitlab.com/singleton-sd/ai-plattform/tools/pdf-context/-/packages) (once per machine or project)5960### Install from GitLab npm registry (recommended)6162The package is **public** — no GitLab token required. Point the `@singleton-sd` scope at the project registry (once per machine or project), in `.npmrc`:6364```ini65@singleton-sd:registry=https://gitlab.com/api/v4/projects/singleton-sd%2Fai-plattform%2Ftools%2Fpdf-context/packages/npm/66```6768Then install:6970```bash71npm install @singleton-sd/ai-plattform-tools-pdf-context72```7374**One-off run** (no install; `.npmrc` scope line still required):7576```bash77npx @singleton-sd/ai-plattform-tools-pdf-context \78 --pdf "C:/path/to/document.pdf" \79 --max-pages 380```8182After install, the CLI binary is `pdf-context` (from `node_modules/.bin`).8384### Install from source (development)8586```bash87git clone git@gitlab.com:singleton-sd/ai-plattform/tools/pdf-context.git88cd pdf-context89yarn install90```9192When working inside the ai-plattform workspace, the tool repo is at `tools/pdf-context/`.9394## Workflow9596```text97Task progress:98- [ ] Confirm pdf path(s)99- [ ] Install `@singleton-sd/ai-plattform-tools-pdf-context` if not present (see Prerequisites)100- [ ] Run pdf-context for each PDF101- [ ] Route large or scanned PDFs to pdf-to-markdown when needed102- [ ] Classify, pick date, propose filename(s)103- [ ] Present proposals (rename only if user confirms)104```1051061. Resolve inputs.107 - Accept a single PDF, a folder, or a batch list.108 - Work from absolute paths.109 - For bulk renames, create a manifest with original path, proposed path, inferred date, date evidence, document type, confidence, and notes.1101112. Extract enough content.112 - Prefer Node.js tools for all extraction, parsing, manifest generation, and renaming commands.113 - **Always start with `pdf-context`** — use the published CLI (do not hand-roll extraction unless the tool fails):114115```bash116pdf-context \117 --pdf "C:/path/to/document.pdf" \118 --max-pages 3119```120121If the package is not on PATH, use `npx @singleton-sd/ai-plattform-tools-pdf-context`.122123When developing from source inside ai-plattform:124125```bash126node tools/pdf-context/extract_context.mjs \127 --pdf "C:/path/to/document.pdf" \128 --max-pages 3129```130131 - Parse the JSON stdout for `page_count`, `metadata`, `pages`, `combined_text`, and `likely_scanned`.132 - If `page_count` ≤ 3 and `likely_scanned` is `false`, use that JSON as the evidence source for classification, date selection, and filename proposals.133 - Use `metadata.creation_date` / `metadata.mod_date` (already `YY-MM-DD`) as date hints, then apply the date selection table using text from `pages` or `combined_text`.134 - If `page_count` > 3, use the [`documents/pdf-to-markdown`](../pdf-to-markdown/SKILL.md) skill instead of loading the whole PDF into context.135 - If `likely_scanned` is `true`, route through the OCR-capable mode in `documents/pdf-to-markdown`; do not create ad hoc Python extraction scripts.136 - Stop once there is enough evidence for a high-confidence name.1371383. Classify the document.139 - Identify the document type from headings, labels, issuer, and repeated terms.140 - Prefer specific types such as `bank-statement`, `driver-licence`, `medical-report`, `pathology-result`, `invoice`, `receipt`, `insurance-notice`, or `tax-notice`.141 - Use `unknown-document` when evidence is weak.1421434. Build the proposed filename.144 - Apply the date rules first.145 - Use human-readable Title Case words separated by spaces after the date.146 - Add person/entity or issuer/provider when visible.147 - Add a safe identifier only when useful, such as account last four digits, licence state, patient name, claim number, or document reference.148 - Avoid full account numbers, full licence numbers, Medicare numbers, tax file numbers, or other high-risk identifiers.1491505. Verify and rename.151 - Present proposed names before renaming unless the user explicitly asked for immediate renaming.152 - Use filesystem-safe move/rename commands and avoid overwrites.153 - After renaming, report the old path, new path, and any low-confidence decisions.154155## Confidence Rules156157Use high confidence only when the document type and date are both directly supported by text or reliable metadata. Use medium confidence when the type is clear but the best date needed judgment. Use low confidence when the file is scanned poorly, mostly blank, encrypted, or has conflicting document labels.158159For low-confidence items:160161- Keep `unknown-document` or `unclassified` in the filename.162- Use today's date only when no document date is reliable.163- Do not invent issuers, dates, names, or categories.164- Include a short note explaining what could not be verified.165166## Reporting Template167168```text169PDF rename proposals1701711. {original_filename}172 Proposed: {YY-MM-DD-name.pdf}173 Basis: {document type}, {date source}, {issuer/provider}174 Confidence: {high|medium|low}175 Notes: {only if needed}176177Renamed files:178- {old_path} -> {new_path}179```180181## Troubleshooting182183| Problem | Action |184| ------- | ------ |185| Package not found / 404 on install | Add the `@singleton-sd` scope registry line to `.npmrc` (see Prerequisites) |186| `pdf-context` not on PATH | Use `npx @singleton-sd/ai-plattform-tools-pdf-context` |187| `likely_scanned: true` | Re-run via [`documents/pdf-to-markdown`](../pdf-to-markdown/SKILL.md) with `--mode hybrid` and OCR |188| `page_count` > 3 | Use [`documents/pdf-to-markdown`](../pdf-to-markdown/SKILL.md) for full extraction |189| Empty or conflicting dates | Fall back to date selection rules; use today's date only when no document date is reliable |190191## Additional resources192193- Tool package: [`@singleton-sd/ai-plattform-tools-pdf-context`](https://gitlab.com/singleton-sd/ai-plattform/tools/pdf-context/-/packages)194- Full conversion for large/scanned PDFs: [`documents/pdf-to-markdown`](../pdf-to-markdown/SKILL.md)195- Tool repo: [`pdf-context`](https://gitlab.com/singleton-sd/ai-plattform/tools/pdf-context)