README (567B)
1 pdfpages - count the pages of a PDF 2 3 This was made by AI. I know neither C++ nor Poppler's API. This is the script 4 I use to get a list of PDFs with their page count. 5 6 #!/bin/sh -e 7 8 list="page-count.txt" 9 cd "$HOME/data/books" 10 11 for f in *.pdf; do 12 if [ ! -s "$list" ] || ! grep "$f" "$list" >> "$list.tmp"; then 13 pdfpages "$f" >> "$list.tmp" 14 fi 15 done 16 17 sort -V "$list.tmp" > "$list" 18 rm "$list.tmp" 19 20 To use pdfinfo instead, replace pdfpages with the following: 21 22 pages="$(pdfinfo "$f" | grep Pages)" 23 pages="${pages##* }" 24 echo "$pages: $f" >> "$list.tmp"