A Python CLI tool to split multiple PDF files into individual pages in bulk. Perfect for processing large batches of multi-page PDFs quickly and efficiently.
- 📄 Split multiple PDFs at once from a directory
- 🔢 Zero-padded page numbers for proper sorting
- 📁 Custom output directory support
- 📊 Progress tracking with detailed summary
- ⚡ Fast batch processing
- 🛡️ Error handling for corrupted files
- Python 3.6+
- PyPDF2
- Clone this repository:
git clone https://github.com/sumanth-0/100LinesOfPythonCode.git
cd 100LinesOfPythonCode/#1007_Bulk_PDF_Splitter- Install dependencies:
pip install PyPDF2Basic usage (output goes to input_folder/split_pdfs):
python bulk_pdf_splitter.py <input_folder>With custom output directory:
python bulk_pdf_splitter.py <input_folder> <output_folder>Split all PDFs in the ./documents folder:
python bulk_pdf_splitter.py ./documentsSplit PDFs and save to custom location:
python bulk_pdf_splitter.py ./documents ./output/split_pagesPages are saved with the format: {original_filename}_page_{page_number}.pdf
Example:
- Input:
report.pdf(5 pages) - Output:
report_page_001.pdfreport_page_002.pdfreport_page_003.pdfreport_page_004.pdfreport_page_005.pdf
Output directory: ./documents/split_pdfs
Found 3 PDF file(s) to process
Processing: report.pdf (5 pages)
Created: report_page_001.pdf
Created: report_page_002.pdf
Created: report_page_003.pdf
Created: report_page_004.pdf
Created: report_page_005.pdf
Processing: presentation.pdf (10 pages)
Created: presentation_page_001.pdf
Created: presentation_page_002.pdf
...
==================================================
Summary: Processed 3/3 files
Total pages extracted: 25
Output saved to: ./documents/split_pdfs
The tool includes error handling for:
- Invalid directory paths
- Corrupted PDF files
- Permission errors
- Missing dependencies
This project is part of the 100 Lines of Python Code repository.
Contributions are welcome! Please check the contributing guidelines.
This tool was created to address Issue #1007.