1

Looking for newer easier solution than found here: How to count pages in multiple PDF files?

or at least explanation on how to download and install cygwin

PR1
  • 21
  • 1
  • 3

2 Answers2

1

Beautiful Excel and VBA solution here: https://www.extendoffice.com/documents/excel/5330-excel-vba-pdf-page-count.html

  1. Open a worksheet where you want to get the Pdf files and page numbers.
  2. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
  3. Click Insert > Module, and paste the following macro in the Module Window. VBA code: List all Pdf file names and page numbers in worksheet:
    Sub Test()
        Dim I As Long
        Dim xRg As Range
        Dim xStr As String
        Dim xFd As FileDialog
        Dim xFdItem As Variant
        Dim xFileName As String
        Dim xFileNum As Long
        Dim RegExp As Object
        Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
        If xFd.Show = -1 Then
            xFdItem = xFd.SelectedItems(1) & Application.PathSeparator
            xFileName = Dir(xFdItem & "*.pdf", vbDirectory)
            Set xRg = Range("A1")
            Range("A:B").ClearContents
            Range("A1:B1").Font.Bold = True
            xRg = "File Name"
            xRg.Offset(0, 1) = "Pages"
            I = 2
            xStr = ""
            Do While xFileName <> ""
                Cells(I, 1) = xFileName
                Set RegExp = CreateObject("VBscript.RegExp")
                RegExp.Global = True
                RegExp.Pattern = "/Type\s*/Page[^s]"
                xFileNum = FreeFile
                Open (xFdItem & xFileName) For Binary As #xFileNum
                    xStr = Space(LOF(xFileNum))
                    Get #xFileNum, , xStr
                Close #xFileNum
                Cells(I, 2) = RegExp.Execute(xStr).Count
                I = I + 1
                xFileName = Dir
            Loop
            Columns("A:B").AutoFit
        End If
    End Sub

Copy

  1. After pasting the code, and then press F5 key to run this code, and a Browse window is popped out, please select the folder that contains the Pdf files you want to list and count page numbers, see screenshot:

  2. And then, click OK button, all Pdf file names and page numbers are listed into the current worksheet, see screenshot:

Rohit Gupta
  • 5,096
PR1
  • 21
  • 1
  • 3
1

One can use PDFsam Basic:

  • gratis
  • runs on Microsoft Windows 10, some other Windows versions, Mac OS X and Linux
  • portable version available (at least on Windows)
  • can easily count the number of pages in several PDF files at once:

enter image description here

Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400