Take the 2-minute tour ×

I'm trying to extract all pages of several pdf's at the same time.

Now it does work with:

for %%I in (*.pdf) do "pdftk.exe" "%%I" burst

But I don't get all the pages, because for every new document he overwrites previous extracted pages.

So I tried:

for %%I in (*.pdf) do "pdftk.exe" "%%I" burst output "%%~nI_%02d.pdf"

But then it doenst work at all... Any ideas?

share|improve this question
add comment

1 Answer

Try the following to burst all PDF files of the current directory into numbered single-page PDF files:

@echo off

for %%F in (*.pdf) do call :burst "%%F"

goto xit

set name=%1
if not [%name:~1,5%]==[burst] (
  pdftk %1 burst output "burst_%~n1_%%04d.pdf"
  for %%d in (doc_data.txt) do del %%d
goto :EOF


The script prepends "burst_" to all generated filenames to avoid a clash between the original PDF files and the newly created ones. %%04d tells pdftk to add the page number as four digits with leading zeroes. Double % is needed to escape the CMD shell.

share|improve this answer
add comment

Your Answer


