Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'pdfseparate': Format output file name as page number with leading zeroes

Tags:

unix

pdf

poppler

pdfseparate requires to specify %d as PDF-page-pattern which is replaced by the page number.

$ pdfseparate CFL_1115_ISSUU.pdf cfl-%d.pdf works. It sets separated output file names as cfl-1.pdf, cfl-2.pdf, ..., cfl-10.pdf etc.

Now I need to add leading 0 to fix the file name string length. So when I try to use formatting characters in command $ pdfseparate CFL_1115_ISSUU.pdf cfl-%04d.pdf, it gives error Syntax Error: 'cfl-%04d.pdf' must contain '%d' if more than one page should be extracted

Can anybody suggest if such formatting is possible?

like image 335
Amit Patel Avatar asked Dec 09 '15 06:12

Amit Patel


1 Answers

On my system (Mac OS X), using the most recent version of Poppler, v0.42.0, this command works as expected:

$ pdfseparate -l 10 PDF32000_2008.pdf cfl-%04d.pdf

$ ls -l cfl-*.pdf
-rw-r--r--  1  kp   staff    11475 23 Mär 18:58 cfl-0001.pdf
-rw-r--r--  1  kp   staff    91252 23 Mär 18:58 cfl-0002.pdf
-rw-r--r--  1  kp   staff  8334441 23 Mär 18:58 cfl-0003.pdf
-rw-r--r--  1  kp   staff  8334443 23 Mär 18:58 cfl-0004.pdf
-rw-r--r--  1  kp   staff  8334444 23 Mär 18:58 cfl-0005.pdf
-rw-r--r--  1  kp   staff    93209 23 Mär 18:58 cfl-0006.pdf
-rw-r--r--  1  kp   staff    89540 23 Mär 18:58 cfl-0007.pdf
-rw-r--r--  1  kp   staff    64383 23 Mär 18:58 cfl-0008.pdf
-rw-r--r--  1  kp   staff  8334444 23 Mär 18:58 cfl-0009.pdf
-rw-r--r--  1  kp   staff   116229 23 Mär 18:58 cfl-0010.pdf
like image 57
Kurt Pfeifle Avatar answered Nov 15 '22 08:11

Kurt Pfeifle