How thanhphamtmu/word2pdf-batch works
Project type and purpose
• This is a single-process, CLI batch-conversion tool written in Python.
• It scans a user-supplied directory for Word documents and images, normalizes filenames, groups related images, converts each group or document to PDF, and writes outputs to separate folders.
1 → 2: User invokes the script with a folder path.
2 → 3: Scanner produces normalized file list → Prefix Grouper builds batches.
3 → 4 and 3 → 5:
• Word files go to Word Converter.
• Image groups go to Image Converter.
4 & 5 → 6: Converted intermediate PDFs are saved into converted_tmp.
6 → 7: Finalize or move PDFs into converted_pdf.
Architectural patterns & design principles
• Pipeline architecture: each stage performs a single responsibility.
• Separation of concerns: file scanning, grouping, conversion, and storage are distinct.
• External-dependency isolation: conversion modules encapsulate calls to COM or PIL.
Technologies & frameworks
• Python 3.8+
• docx2pdf library (depends on MS Word COM)
• Pillow (PIL fork) for image handling
• Standard os, shutil, re modules for filesystem and regex operations
Essential elements
• Notes: grouping rules, temp vs final paths.