Adds cbz related scripts

This commit is contained in:
Nemo 2018-02-19 02:27:47 +05:30
parent 1e5aa9e6b6
commit 719e1e237c
2 changed files with 71 additions and 0 deletions

15
cbz-convertor.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
# Usage: Zips given directories into .cbz (Comic Book ZIP) archives of the smame name (eg "folder name.cbz").
COMIC_ROOT="/home/nemo/Downloads/Books/Comics"
cd $COMIC_ROOT
while read comic_dir; do
if [[ -f "$comic_dir.cbz" ]]; then
echo "[Exists] $comic_dir.cbz"
else
echo "[DL] $comic_dir"
cbz.sh -k "$comic_dir" > /dev/null
fi
done < <(find . -mindepth 2 -maxdepth 2 -type d)

56
cbz.sh Executable file
View File

@ -0,0 +1,56 @@
#! /bin/bash
# Usage: Zips given directories into .cbz (Comic Book ZIP) archives of the smame name (eg "folder name.cbz").
remove_flag="m"
recursive_flag="r"
test_flag="T"
compression="9"
open_flag="false"
while getopts "kho" flag
do
case $flag in
"k") #clears remove flag
echo "Keeping originals."
remove_flag=""
;;
"h") #print usage
echo "USAGE: cbz [-k][-h] DIRECTORY ..."
echo "-h print this help screen"
echo "-k keep originals"
exit 0
;;
# "o")
# open_flag="true"
# ;;
esac
done
#exec > >( lolcat ) # send stdout to lolcat
#exec 2>&1 # merge stderr into stdout
echo "Running: zip -$remove_flag$recursive_flag$test_flag$compression out.cbz in -x *.DS_Store *[Tt]humbs.db"
for target in "$@"
do
if [[ -e $target ]]
then
if [[ -d $target ]]
then
echo "Archiving \"$target\""
# -m delete originals, -r recursive, -T test zip, -9 maximum compression, -x exclude list
zip -"$remove_flag$recursive_flag$test_flag$compression" "$target.cbz" "$target" -x "*.DS_Store" "*[Tt]humbs.db"
# if [[ $open_flag == "true" ]]
# then
# echo "Opening $target.cbz"
# open "$target.cbz"
# fi
else
echo "\"$target\" is not a directory or not readable. Skipping."
fi #-d
else
echo "\"$target\" does not exist."
fi
done