开发者

Remove First Page from a Series of PDFs

开发者 https://www.devze.com 2023-01-20 09:26 出处:网络
I have a ser开发者_开发技巧ies 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 us

I have a ser开发者_开发技巧ies 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?


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


shopt -s nullglob
for file in *.pdf
do
 out=${file%.pdf}_page1.pdf
 pdftk "$file" cat 1 output "$out"
done
0

精彩评论

暂无评论...
验证码 换一张
取 消