Skip to content

Instantly share code, notes, and snippets.

@LouisRitchie
Last active June 15, 2018 02:16
Show Gist options
  • Save LouisRitchie/9a90badb920bea29c65100a757b1c95d to your computer and use it in GitHub Desktop.
Save LouisRitchie/9a90badb920bea29c65100a757b1c95d to your computer and use it in GitHub Desktop.
A script that takes a .djvu file and generates another .djvu using the given page range. You can run this many times with https://gist.github.com/LouisRitchie/a797882ce9b934b2f08a649bf7261776 to a bunch of chapters out of a djvu.
# USAGE: ./script.sh [input file] [start page] [end page] [output file]
# Using this script asynchronously would be extremely painful
# > you're a big guy
# for you
input_file=$1
output_file=$4
start_page=$2
end_page=$3
range=$(seq $start_page $end_page)
temp_files=$(echo $range | tr '\n' ' ' | sed -e "s/ /\.djvu /g") # 1.djvu 2.djvu 3.djvu
for i in $range
do
djvused $input_file -e "select $i; save-page-with $i.djvu"
done
djvm -c $output_file $temp_files
rm $temp_files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment