Search code examples
bashpdfpdftk

Remove First Page from a Series of PDFs


I have a series of PDFs (Computer Gaming World issues) and I want to remove the first page from the pdf file of each issue. There are 100 issues, so a GUI is just not gonna cut it. I used pdftk to remove the first page from one issue:

pdftk 1981_1112_issue1.pdf cat 1 output 1.pdf

My problem is that I do not want to have to modify and run this command for every pdf issue as that is not much better than the GUI method.

Using *.pdf as an input does not seem to work. What other ways can I use to run pdftk on every PDF?


Solution

  • Loop on all issues. Output is named after issue by replacing "issue" by "output". The first line extract page 1, the second line extract the other pages:

    for issue in *_issue*.pdf
    do
        pdftk ${issue} cat 1 output page1_${issue/issue/output}
        pdftk ${issue} cat 2-end output otherpages_${issue/issue/output}
    done