Last active
February 25, 2023 00:50
-
-
Save seppo0010/0802b7bc3ffc0d9ffda8a11714c5f793 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -Eeux | |
f=493393291-Borda-Manual-de-Contratos-2020.pdf | |
prev_page=0 | |
prev_title="" | |
while read line; do | |
this_page=$(echo $line | awk '-F:' '{print $1}') | |
this_title=$(echo $line | awk '-F:' '{print $2}' |xargs) | |
target="${f/.pdf/} - $prev_title.pdf" | |
if [ "$prev_page" -gt 0 ] && [ ! -f "$target" ]; then | |
pdfjam "$f" "$prev_page-$this_page" -o "$target" | |
fi | |
prev_page="$this_page" | |
prev_title="$this_title" | |
done < <(pdfgrep -n 'CAPÍTULO' "$f") | |
target="${f/.pdf/} - $prev_title.pdf" | |
if [ "$prev_page" -gt 0 ] && [ ! -f "$target" ]; then | |
pdfjam "$f" "$prev_page-" -o "$target" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment