😫 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 GUI Developer (PyQt6 Specialist)
**Task:** Create "Smart PDF Renamer" Desktop App
**Objective:** A batch renaming tool that extracts metadata (Invoice#, Date) from PDF content.
**Tech Stack:**
* Language: Python 3.10+
* GUI Library: PyQt6 (Cross-platform)
* Parser: pdfplumber, Regex
* Packaging: PyInstaller
**Functional Requirements:**
1. **UI Layout (PyQt6):**
* **Input:** Folder Selector.
* **Pattern:** Regex Builder (e.g., `INV-\d+`).
* **Template:** Naming Schema `{RegexMatches[0]}_{Date}.pdf`.
* **Review:** Table showing "Current Name" -> "New Name" (Editable).
* **Action:** "Commit Renames".
2. **Core Logic:**
* Extract text from page 1.
* Find matches; Dry-run to generate preview.
* `os.rename` with duplicate handling (append `_1`).
* **Threading:** Extraction loop runs in background.
3. **Deliverables:**
* `main.py`: Complete source code.
* `requirements.txt`: Dependencies.
* **Build Instructions:**
* Windows: `pyinstaller --onefile --noconsole main.py`
* macOS: `pyinstaller --windowed --noconsole main.py`
🧠 Prompt Decoding
- Dry Run: Essential for file renaming tools. Never rename without preview.
🛠️ Instructions
- Copy Prompt → Run with preview.
- Review names → Apply.