-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpagecount.py
More file actions
29 lines (23 loc) · 897 Bytes
/
Copy pathpagecount.py
File metadata and controls
29 lines (23 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
from pdf2image import pdfinfo_from_path
from tqdm import tqdm
# Folder containing all PDF files
folder_path = r"C:\Users\User\Downloads\CC-20251022T080331Z-1-001\Ragib"
# Path to poppler bin folder
poppler_path = r"C:\poppler\Library\bin"
total_pages = 0
pdf_page_counts = {}
for filename in tqdm(os.listdir(folder_path)):
if filename.lower().endswith(".pdf"):
file_path = os.path.join(folder_path, filename)
try:
info = pdfinfo_from_path(file_path, poppler_path=poppler_path)
num_pages = info["Pages"]
pdf_page_counts[filename] = num_pages
total_pages += num_pages
except Exception as e:
print(f"Error reading {filename}: {e}")
print("\n--- Page Counts ---")
for pdf, count in pdf_page_counts.items():
print(f"{pdf}: {count} pages")
print(f"\nTotal pages across all PDFs: {total_pages}")