39 lines
832 B
Bash
Executable File
39 lines
832 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -Eeuo pipefail
|
|
export LANG=ja_JP.UTF-8
|
|
export LANGUAGE=ja_JP:ja
|
|
export LC_ALL=ja_JP.UTF-8
|
|
export LC_CTYPE=ja_JP.UTF-8
|
|
|
|
DIR="${1:-.}"
|
|
|
|
if [[ ! -d "$DIR" ]]; then
|
|
echo "Error: Directory '$DIR' does not exist."
|
|
exit 1
|
|
fi
|
|
|
|
if ! mokuro --parent_dir "$DIR" --disable_confirmation; then
|
|
echo "Error: mokuro command failed."
|
|
exit 1
|
|
fi
|
|
|
|
cd "$DIR" || exit
|
|
|
|
for f in *.mokuro; do
|
|
[[ -e "$f" ]] || continue
|
|
base="${f%.mokuro}"
|
|
dir="$base"
|
|
zipfile="$base.zip"
|
|
if [[ -f "$zipfile" ]]; then
|
|
echo "Warning: Zip file $zipfile already exists, skipping."
|
|
elif [[ -d "$dir" ]]; then
|
|
echo "Zipping: $zipfile <- $f $dir/"
|
|
7z a -tzip "$zipfile" "$f" "$dir"
|
|
else
|
|
echo "Warning: Directory '$dir' not found for '$f', skipping."
|
|
fi
|
|
done
|
|
|
|
rm -rf ./*.html
|