Intelligent PDF date extraction and renaming tool
DateForge automatically extracts dates from your PDF documents and renames them with a YYYYMMDD_ prefix for perfect chronological sorting. Process hundreds of PDFs in seconds with parallel processing and smart text extraction.
- Extracts dates from PDF content using intelligent multi-tier strategy
- Supports all common date formats (numeric, text, ordinals)
- Handles both digital and scanned PDFs
- Parallel processing using up to 8 worker processes
- Processes 30+ files per second on modern hardware
- Smart optimization: only scans necessary pages
- Renames PDFs with
YYYYMMDD_prefix for chronological sorting - Moves undated PDFs to
* No Date Found/folder - Moves non-PDF files to
* Not a PDF/folder - Asterisk prefix keeps special folders at the top
DateForge recognizes all these formats and more:
03/09/2025 → September 3, 2025
2025-09-03 → September 3, 2025
3.9.2025 → September 3, 2025
3rd September 2025 → September 3, 2025
September 3rd, 2025 → September 3, 2025
3 Sep 2025 → September 3, 2025
21st January 2025 → January 21, 2025
Jan 21, 2025 → January 21, 2025
Supports:
- Full month names (September, January) and abbreviations (Sep, Jan)
- Ordinal suffixes (st, nd, rd, th)
- Multiple date separators (/, -, .)
- Case-insensitive matching
- Python 3.13 or higher
- UV package manager - Install UV
# Quick UV installation
curl -LsSf https://astral.sh/uv/install.sh | sh# Clone the repository
git clone https://github.com/yourusername/dateforge.git
cd dateforge
# Install dependencies
uv sync
# Optional: Install OCR support for scanned PDFs
uv sync --extra ocr# Run the script
./run.shOr manually:
uv run python main.py- Run the script:
./run.sh - Enter folder path:
/path/to/your/pdfs - Watch the magic: DateForge processes files in parallel
- Review results: Check the summary statistics
Processing 75 PDFs using parallel workers...
RENAMED: Invoice_Sept.pdf -> 20250903_Invoice_Sept.pdf
RENAMED: Receipt.pdf -> 20250815_Receipt.pdf
NO DATE: Brochure.pdf -> * No Date Found/
============================================================
PROCESSING SUMMARY
============================================================
Total PDFs found: 82
Already formatted: 7
Successfully renamed: 43
No date found: 32
Errors: 0
Processing time: 2.20s
Speed: 37.25 files/sec
============================================================
DateForge uses a sophisticated three-tier approach:
-
Tier 1: PyMuPDF Text Extraction (fastest)
- Extracts text directly from PDF structure
- Works for 90%+ of digital PDFs
- Scans first 3 pages
-
Tier 2: pdfplumber Extraction (better accuracy)
- Enhanced text extraction for complex layouts
- Handles tables and multi-column documents
- Fallback if Tier 1 finds insufficient text
-
Tier 3: OCR Fallback (optional, for scanned PDFs)
- Optical character recognition for image-based PDFs
- Only activates if text extraction fails
- Requires optional OCR dependencies
- Uses pre-compiled regex patterns for speed
- Leverages
python-dateutilfor flexible parsing - Validates dates within 1900-2100 range
- Selects earliest valid date if multiple found
Your Folder/
├── 20250903_Invoice.pdf ← Renamed with date
├── 20250815_Receipt.pdf ← Renamed with date
├── * No Date Found/ ← Undated PDFs
│ ├── Brochure.pdf
│ └── Flyer.pdf
└── * Not a PDF/ ← Non-PDF files
├── document.docx
└── image.jpg
MAX_TEXT_SCAN_PAGES = 3 # Pages to scan for text
MAX_OCR_PAGES = 2 # Pages to OCR if needed
MIN_TEXT_THRESHOLD = 50 # Min chars for valid text
OCR_ZOOM = 1.5 # OCR resolution multiplier
MIN_YEAR = 1900 # Earliest valid year
MAX_YEAR = 2100 # Latest valid yearTested on MacBook Pro M1 with 75 PDFs:
- Processing Time: 2.20 seconds
- Speed: 37.25 files/second
- Success Rate: 57% dates found
- Worker Processes: 8 parallel workers
- SSD Storage: Store PDFs on SSD for faster I/O
- Skip OCR: Don't install OCR dependencies if not needed
- Batch Processing: Process large folders at once
- Modern CPU: More cores = more parallel processing
| Package | Purpose | Size |
|---|---|---|
pymupdf |
Fast PDF parsing | ~50MB |
pdfplumber |
Enhanced text extraction | ~20MB |
python-dateutil |
Flexible date parsing | ~300KB |
tqdm |
Progress bars | ~100KB |
Total Core Size: ~500MB
| Package | Purpose | Size |
|---|---|---|
easyocr |
Optical character recognition | ~100MB |
numpy |
Array operations | ~50MB |
pillow |
Image processing | ~10MB |
| PyTorch (via easyocr) | Neural networks | ~500MB+ |
Total with OCR: ~2-3GB
# Install UV
curl -LsSf https://astral.sh/uv/install.sh | sh# Reinstall dependencies
uv sync --reinstall# Install optional OCR dependencies
uv sync --extra ocr# Make script executable
chmod +x run.sh- Check Issues for known problems
- Search Discussions for community help
- Review the CHANGELOG for version-specific notes
dateforge/
├── main.py # Main application logic
├── run.sh # Launcher script
├── pyproject.toml # Project configuration
├── README.md # This file
├── CHANGELOG.md # Version history
└── .dateforge-venv/ # Virtual environment (created on first run)
scan_pdf_for_date()- Multi-tier date extractionextract_date_with_pymupdf()- Fast text extractionextract_date_with_pdfplumber()- Enhanced extractionextract_date_with_ocr()- OCR fallbackextract_date_from_text()- Pattern matching and parsing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
Licensed under Err0r.dev Open Use License
- Built with PyMuPDF for PDF processing
- Uses pdfplumber for enhanced text extraction
- Powered by python-dateutil for flexible date parsing
- Optional OCR via EasyOCR
Current version: 1.0.0
See CHANGELOG.md for version history.