Skip to content

Commit

Permalink
enhance process_images script with more helpful checks and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fhennig committed Nov 5, 2024
1 parent 8d01190 commit afa7f83
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion website/scripts/process_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,25 @@ fi
# Directory containing images
IMAGE_DIR="$1"

# Check if the directory exists
if [ ! -d "$IMAGE_DIR" ]; then
echo "Error: Directory '$IMAGE_DIR' does not exist."
exit 1
fi

# Enable nullglob to avoid errors when no .jpg files are found
shopt -s nullglob

# Count the number of jpg files
jpg_files=("$IMAGE_DIR"/*.jpg)

if [ ${#jpg_files[@]} -eq 0 ]; then
echo "No JPG files found in '$IMAGE_DIR'."
exit 0
fi

# Loop over all jpg files in the directory
for img in "$IMAGE_DIR"/*.jpg; do
for img in "${jpg_files[@]}"; do
# Extract the filename without extension
filename=$(basename "$img" .jpg)

Expand Down

0 comments on commit afa7f83

Please sign in to comment.