12345678910111213141516171819202122232425262728 |
- pagesA=$(pdftk abclager1.pdf dump_data | awk '/NumberOfPages/ {print $2}')
- pagesB=$(pdftk abclager2_rev.pdf dump_data | awk '/NumberOfPages/ {print $2}')
- if (( pagesA < pagesB )); then
- min=$pagesA
- max=$pagesB
- remainder="B"
- else
- min=$pagesB
- max=$pagesA
- remainder="A"
- fi
- for (( i = 1; i <= min; i++ )); do
- pages+=(A"$i" B"$i")
- done
- for (( i = min+1; i <= max; i++ )); do
- pages+=("$remainder$i")
- done
- pdftk A=abclager1.pdf B=abclager2_rev.pdf cat "${pages[@]}" output output.pdf
|