From 719e1e237ce5041559574f4bf55b869a91da9648 Mon Sep 17 00:00:00 2001 From: Nemo Date: Mon, 19 Feb 2018 02:27:47 +0530 Subject: [PATCH] Adds cbz related scripts --- cbz-convertor.sh | 15 +++++++++++++ cbz.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100755 cbz-convertor.sh create mode 100755 cbz.sh diff --git a/cbz-convertor.sh b/cbz-convertor.sh new file mode 100755 index 0000000..3190cf9 --- /dev/null +++ b/cbz-convertor.sh @@ -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) \ No newline at end of file diff --git a/cbz.sh b/cbz.sh new file mode 100755 index 0000000..89541bd --- /dev/null +++ b/cbz.sh @@ -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 \ No newline at end of file