πŸ“„

Smart PDF Rename

Automatically rename PDF files based on their content (title, date, invoice number).

Document ⭐⭐ Intermediate ⏱️ 5 minutes

😫 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 invoices with PDFs. Write a Python script using pdfplumber to:

  1. Extract: Read first page of each PDF.
  2. Find Patterns:
    • Invoice number: regex INV-\\d+ or Invoice #\\d+
    • Date: regex for common date formats
  3. Rename: To format {Invoice_Number}_{Date}.pdf
  4. Dry Run: Default to preview; --apply to 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

  1. Copy Prompt β†’ Run with preview.
  2. Review names β†’ Apply.

Related Workflows

Explore other categories

πŸ“¬

Get Started with Agentic Working

Subscribe to receive updates from AgenticWorking.io

πŸ“– Free eBook Guide πŸ“¦ 7 Ready-to-use Scripts πŸ”” Weekly Tips

No spam, unsubscribe anytime. Join 1,000+ subscribers.