Menu

1 / 2

Build a Bulk PDF Invoice Renamer in 55 Lines of Python

DEV Community·Archit Mittal·6 months ago
#f4qxW7Qk
Reading 0:00
15s threshold

Last month, my CA messaged me at 11pm: "Bhai, send all April invoices in a single zip, named properly." I had 47 PDF invoices in my Downloads folder, all with names like Invoice (3).pdf , download.pdf , and INV_FINAL_FINAL_v2.pdf .

Two hours of manual renaming wasn't on my agenda. So I wrote a Python script. By the time my chai was done, the script was done. 47 invoices renamed, audit-ready.

Here's the entire thing — 55 lines, no fluff.

What it does

The script scans a folder of PDF invoices and renames each file to a clean, sortable format:

2026-04-15_AcmeServices_INV-1042_15000.pdf

Enter fullscreen mode

Exit fullscreen mode

It pulls four things from each invoice: the invoice date, vendor name (from the GSTIN line), invoice number, and total amount in ₹. If a field is missing, it falls back to a placeholder so nothing gets lost.

The Code

import re import sys from pathlib import Path from datetime import datetime import pdfplumber

DATE_RE = re .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.