Batch - count pages pdf File

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Basole
Posts: 2
Joined: 11 Oct 2013 09:47

Batch - count pages pdf File

#1 Post by Basole » 11 Oct 2013 09:50

Hi guys, it is possible that one batch count the number of pages from a PDF file?

npocmaka_
Posts: 517
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Batch - count pages pdf File

#2 Post by npocmaka_ » 11 Oct 2013 10:11

Off course it is.Despite it's in binary format some of the metadata is in plain text:

Code: Select all

for /f "tokens=4 delims=/^< " %P in ('type Burov.pdf^| find "<</Type/Pages/Count"') do echo %P

in batch file you'll need to double the %-es.

the metadata that contains page numbers starts with <</Type/Pages/Count and it can be displayed with type command.
I'll need a little bit more testing to handle different cases e.g. spaces between words.Probably a little bit more sophisticated FINDSTR expression.

But... Probably wont be able to handle all the cases...PDF metada format is too flexible.

Basole
Posts: 2
Joined: 11 Oct 2013 09:47

Re: Batch - count pages pdf File

#3 Post by Basole » 11 Oct 2013 14:35

Ok npocmaka_, tks. :D

Post Reply