Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of PDFs and for each of them, I would like to remove pages 2 and 4, then glue the PDF back together. Is there a clever way to do this using a command-line utility?

share|improve this question

The PDF Toolkit can do this from the command line:

pdftk input.pdf cat 1 3 output output.pdf

cat 1 3 extracts pages 1 and 3 from input.pdf and outputs it to output.pdf. To cycle through all on Windows, use

for %f in (*.pdf) do pdftk %f cat 1 3 output %~nfo.pdf

%~nf returns an extension-less version of %f as extracted from the list *.pdf. Therefore, using %~nfo.pdf produces, as output, a file <input>o.pdf for input <input>.pdf. For using inside a batch file, use %%f and %%~nfo.pdf.

For more information, see the PDF Toolkit man page.

share|improve this answer

PDF Split and Merge and more specifically pdfsam-console mentioned on that page can do this.

share|improve this answer
Note that this requires JRE. – mbrownnyc Mar 8 '13 at 15:05

Yes, from what you said, I think you can use a PDF Merger. How? You just offer the page range of your pdf file except for page 2 and 4. for example 1,3,5-last page number. Then merge them, thus you will get desired part and delete 2 and 4. Do as what I state! It's very easy to achieve!

you may try PDF Merger:

The PDF Merger is a professional but easy-to-use PDF file Combiner & Joiner designed to merge PDF files for more convenient organizing, archiving and printing in batch. It allows you to merge PDF according to your needs with many different merge modes. With it you are flexible to merge multiple PDF files to create a single one or merge specific pages to a new PDF file, even merge any pages of several different PDF files to one.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .