Split PDF with pdfseparate / cpdf

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Split PDF with pdfseparate / cpdf Mon Aug 22, 2016 5:39 am • by escobol
Hello,

I got problem with splitting pdf files (PDF file that got more than 10 pages to separate pdfs).

I am trying to use pdfseparate or cpdf.

I got rule to monitor folder, if there is a new PDF run shell script.

Shell script:

cpdf -split $1.pdf -o %%_ $1 .pdf

and I got error all the time, the same problem with pdfseparate (i think that the problem is caused by name of the new file)

any help?
escobol
 
Posts: 2
Joined: Mon Aug 22, 2016 5:33 am

Re: Split PDF with pdfseparate / cpdf Mon Aug 22, 2016 12:51 pm • by Mr_Noodle
A couple things:
- Make sure to use the full path to refer to anything (in this case, cpdf).
- Enclose the $1 in double-quotes in case the path contains spaces.

If it still doesn't work after that, turn on debug mode (see sticky article at the top of this forum). That will write out all the output of the script to the logs.
Mr_Noodle
Site Admin
 
Posts: 11879
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Split PDF with pdfseparate / cpdf Mon Aug 22, 2016 2:08 pm • by escobol
OK got it.

/bin/bash

base=$(basename -s .pdf "$1")
pdfseparate "$base".pdf %02d_"$base".pdf


(there was problem with name definition in shell, "$1" was passing .pdf so there was error, without extension everything is ok)
escobol
 
Posts: 2
Joined: Mon Aug 22, 2016 5:33 am


Return to Support