X-Git-Url: http://git.projectaon.org/?p=project-aon.git;a=blobdiff_plain;f=common%2Fscripts%2Fcopy-ebooks.sh;fp=common%2Fscripts%2Fcopy-ebooks.sh;h=3c39738277276dfb79238b5d5a797a21ea0d2994;hp=0000000000000000000000000000000000000000;hb=c6338dc3c2d3299fdf71c128a7b707d7a69762dd;hpb=2bad6d7f32882c37e0ced713ce64832a519f4b47 diff --git a/common/scripts/copy-ebooks.sh b/common/scripts/copy-ebooks.sh new file mode 100755 index 0000000..3c39738 --- /dev/null +++ b/common/scripts/copy-ebooks.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# Copy ebook files for the specified book(s) to a directory structure that's +# ready to be pushed to the public website. +# +# Examples: +# +# copy-ebooks.sh 05sots +# +# list-bookcodes-by-series.sh gs | xargs copy-ebooks.sh + +if [ ! -d "$AONDIR" ]; then + >&2 echo "Please set the AONDIR environment variable" + exit +fi +CURR_DIR=`pwd` + +BASE_DIR="$AONDIR/common/epub" +book_db="$AONDIR/common/sqlite/bookcodes.db" + +for book in $@ +do + row=($(sqlite3 -separator ' ' $book_db "select lang, series from bookcodes where book = '$book';")) + + lang=${row[0]} + series=${row[1]} + + source_dir="$BASE_DIR/$book" + + for format in epub mobi fb2 pdb lrf + do + output_dir="$CURR_DIR/$lang/$format/$series" + mkdir -p "$output_dir" + cp -av "$source_dir/$book.$format" "$output_dir" + done +done