replace zip with run script

This commit is contained in:
2025-09-07 15:08:12 -07:00
parent b0e430e19d
commit 5a53e1a782
4 changed files with 56 additions and 27 deletions

38
run.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/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