Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 1

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

@echo off
setlocal

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

goto xit

:burst
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

:xit
pause
endlocal

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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.