π« The Pain Point
You downloaded 100 invoices all named βdownload.pdfβ or βdoc123.pdfβ. You need them named like βInvoice_2024-01-15_CompanyName.pdfβ for organized filing.
π Agentic Solution
A Content-Based Renamer that reads the PDF and names it intelligently.
Key Features:
- Pattern Matching: Extract invoice numbers, dates, titles using regex.
- Template Naming: Define your naming format.
- Preview Mode: See proposed names before applying.
βοΈ Phase 1: Commander (Quick Fix)
For quick renaming.
Prompt:
βI have a folder
invoiceswith PDFs. Write a Python script using pdfplumber to:
- Extract: Read first page of each PDF.
- Find Patterns:
- Invoice number: regex
INV-\\d+orInvoice #\\d+- Date: regex for common date formats
- Rename: To format
{Invoice_Number}_{Date}.pdf- Dry Run: Default to preview;
--applyto actually rename.Print proposed renames. Skip files where pattern not found.β
Result: Organized file names based on content.
ποΈ Phase 2: Architect (Permanent Tool)
For Accountants/File Managers.
Engineering Prompt:
**Role:** Python Tool Developer
**Task:** Create a "Smart PDF Renamer".
**Requirements:**
1. **GUI:**
* Select folder.
* Pattern builder: Extract invoice #, date, customer name.
* Naming template input with variables.
* Preview table (old name β new name).
* "Apply" button.
* Progress bar.
2. **Logic:**
* Read first 2 pages for content.
* Regex pattern matching.
* Handle duplicate names (add suffix).
* Sanitize filenames.
3. **Deliverables:**
* `pdf_rename.py`
* `run.bat`, `run.sh`
* `requirements.txt`
π§ Prompt Decoding
- Dry Run: Essential for file renaming tools. Never rename without preview.
π οΈ Instructions
- Copy Prompt β Run with preview.
- Review names β Apply.