当前文件夹下PDF文件页码计数

import PyPDF2
import time

import os


file_name = os.listdir(os.getcwd()) # 获取当前路径
file_typ = ".pdf" 
pdf_list = []
b = 0
totalpag = 0
for n in file_name:
    if file_typ in n:         #判断是否是PDF文件
        print("Found PDF file:" + n)
        pdf_list.append(n)
        pdfReader = PyPDF2.PdfFileReader(n)
        pag_num=(pdfReader.numPages)  # 获取当前PDF文件页数
        print(n + " totally have " + str(pag_num) + " pages.")
        totalpag = int(totalpag) + int(pag_num)  # 计算页数
        b += 1                                 #计算pdf 文件数量
    else:
        print(n + " is not a pdf file .")

print("Total " + str(b) + " pdf files, and " + str(totalpag) + " pages in all.")


time.sleep(60)          #窗口保留60s

加班不给钱