Add epub exctraction script
This commit is contained in:
parent
6795a0e703
commit
ece39ef84d
30
arch-config/scripts/pieces/manga-extract-epub.sh
Normal file → Executable file
30
arch-config/scripts/pieces/manga-extract-epub.sh
Normal file → Executable file
@ -1,8 +1,32 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo "Please use this script with a \"PATH\" to a folder containing Manga chapters"
|
||||||
|
$(exit 1); echo "$?"
|
||||||
|
fi
|
||||||
|
|
||||||
|
dir="$1"
|
||||||
|
parentdir="$(dirname "$dir")"
|
||||||
|
filename="$(basename "$dir")"
|
||||||
|
# remove .epub to get output folder name
|
||||||
|
outdir="${filename%.*}"
|
||||||
|
|
||||||
|
cd "$parentdir"
|
||||||
|
|
||||||
|
#echo $parentdir
|
||||||
|
#echo $filename
|
||||||
|
#echo $outdir
|
||||||
|
|
||||||
# 1. extract .epub
|
# 1. extract .epub
|
||||||
|
unzip "$dir" -d "$outdir"
|
||||||
|
|
||||||
# 2. images under "(folder name)/OEBPS/image"
|
# 2. images under "(folder name)/OEBPS/image"
|
||||||
# 3. rename images to "pageXXX.(ext)"
|
mv "$outdir/OEBPS/image/"* "$outdir/"
|
||||||
# 4. move to "(folder name)"
|
|
||||||
# 5. delete folders "META-INF", "OEBPS" and file "mimetype"
|
# 3. delete folders "META-INF", "OEBPS" and file "mimetype"
|
||||||
|
rm -r "$outdir/"{META-INF,OEBPS,mimetype}
|
||||||
|
|
||||||
|
# 4. rename images to "pageXXX.(ext)"
|
||||||
|
cd "$outdir"
|
||||||
|
ls | cat -n | while read n f; do mv "$f" `printf "page%03d.jpg" $n`; done
|
||||||
|
Loading…
Reference in New Issue
Block a user