pdftk.exe - Split existing PDFs into single pages - failing when run from a batch job...

Briguy_572
Briguy_572 used Ask the Experts™
on
I have faxes that are converted to pdf files when they are received and are dumped to a network folder.

Many times, these pdf files have multiple pages.  I need to split the pages into individual pdf files so that they can be processed independantly from each other.

I am using the pdftk.exe utility.  When i run the command manually at the cmd line - it works fine.

example: pdftk.exe C:\Temp\folder1_original\Avaya-phones-value.pdf burst output C:\Temp\Folder2_Burst\Avaya-phones-value-%02d.pdf
Note:  the "%02d" variable will make name the pages with 01, 02, 03, etc in the name.

If i run the same command from within a batch file, the "%" sign in the output filename replaces the intended page numbers with the batch file name (C:\Temp\Folder2_Burst\Avaya-phones-value-C:\Temp\folder1_original\pdftk-burst.bat2d.pdf.

Does anyone have any ideas on how to avoid this?  Is there another way to specify the page numbers, or another variable, etc?  I have tried setting quotes around the output name in the batch file, but no luck.

Thanks
C:\Temp>pdftk.exe C:\Temp\folder1_original\Avaya-phones-value.pdf burst output C:\Temp\Folder2_Burst\Avaya-phones-value

C:\Temp>C:\Temp\folder1_original\pdftk-burst.bat

C:\Temp>pdftk.exe C:\Temp\folder1_original\Avaya-phones-value.pdf burst output C:\Temp\Folder2_Burst\Avaya-phones-value
Unhandled Java Exception:
java.io.FileNotFoundException: C:\Temp\Folder2_Burst\Avaya-phones-value-C:\Temp\folder1_original\pdftk-burst.bat2d.pdf:

   at 0x0056175e (Unknown Source)
   at 0x00561c52 (Unknown Source)
   at 0x00576914 (Unknown Source)
   at 0x0055f634 (Unknown Source)
   at 0x0061e044 (Unknown Source)
   at 0x005e65b2 (Unknown Source)
   at 0x005e33cc (Unknown Source)
   at 0x0055f54e (Unknown Source)
   at 0x0055f5f9 (Unknown Source)

C:\Temp>

Open in new window

Avaya-phones-value.pdf pdftk-burst.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT / Software Engineering Consultant
Top Expert 2016
Commented:
In a BAT script the % sign has special meaning so you will need to "escape" it to actually pass the % sign to the PDTFK toolkit.  Try these two suggestions below and see if one works:

pdftk.exe C:\Temp\folder1_original\Avaya-phones-value.pdf burst output C:\Temp\Folder2_Burst\Avaya-phones-value-%%02d.pdf

pdftk.exe C:\Temp\folder1_original\Avaya-phones-value.pdf burst output C:\Temp\Folder2_Burst\Avaya-phones-value-^%02d.pdf

~bp

Author

Commented:
nailed it - %% was it.
thank you
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
Great, glad to help, thanks.

~bp

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial