Page 1 of 1

Split PDF with pdfseparate / cpdf

PostPosted: 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?

Re: Split PDF with pdfseparate / cpdf

PostPosted: 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.

Re: Split PDF with pdfseparate / cpdf

PostPosted: 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)