How To Get the Page Count for Each PDF File in A Folder
https://www.pdflabs.com/tools/pdftk-server/
combination use of PowerShell and a small free utility PDFtk free that comes with a command-line.
Install the free utility PDFtk and then prepare a PowerShell script like below:
$result = @() $path = [string]$args[0] dir $path\*.pdf | foreach-object{ $pdf = pdftk.exe $_.FullName dump_data $NumberOfPages = [regex]::match($pdf,'NumberOfPages: (\d+)').Groups[1].Value $details = @{ NumberOfPages = $NumberOfPages Name = $_.Name } $result += New-Object PSObject -Property $details } $result $result | export-csv -Path $path\pdf.csv echo "Th result has been saved in $path\pdf.csv file"
The script takes the directory as the argument from the command line to identify which folder you want to scan the PDF files. For example, to scan all PDF files in H: drive to find the page count for each files in that directory, I run:
.\pdf.ps1 H:
No comments:
Post a Comment
Note: only a member of this blog may post a comment.