#!/bin/bash # Specify the input directory INPUT_DIR="../../assets/pics/gallery/sculpture" # Ensure ImageMagick is installed for filename in $(find "$INPUT_DIR" -type f -name "*.heic"); do # Define the output file name CONVERTED_FILE="${filename%.heic}.webp" # Skip if already converted if [[ -f "$CONVERTED_FILE" ]]; then echo "Skipping $filename, already converted." continue fi # Convert HEIC to WEBP echo "Converting $filename to $CONVERTED_FILE..." convert "$filename" -quality 85 "$CONVERTED_FILE" # Verify conversion success if [[ -f "$CONVERTED_FILE" ]]; then # Create a blank text file txt_file="${CONVERTED_FILE%.webp}.txt" echo -e "" > "$txt_file" echo "Successfully converted $filename to $CONVERTED_FILE and created ${txt_file}" else echo "Error converting $filename" fi done