This script works on Mint 20. HEIC files are converted and moved to a folder (created by the script) called ‘JPEG”.

#!/bin/bash

# ============================================================
#  convert_heic.sh
#  Run from inside the folder containing your HEIC files.
# ============================================================

# ── 1. Install libheif-examples if needed ───────────────────
if ! command -v heif-convert &>/dev/null; then
    echo "[*] Installing libheif-examples..."
    sudo apt-get update -qq
    sudo apt-get install -y libheif-examples
else
    echo "[*] heif-convert already installed, skipping."
fi

# ── 2. Create output directory ──────────────────────────────
mkdir -p JPEG
echo "[*] Output folder: $(pwd)/JPEG"

# ── 3. Find HEIC files ──────────────────────────────────────
mapfile -d '' FILES < <(find . -maxdepth 1 -iname "*.heic" -print0)

if [[ ${#FILES[@]} -eq 0 ]]; then
    echo "[!] No HEIC files found in $(pwd). Exiting."
    exit 1
fi

echo "[*] Found ${#FILES[@]} HEIC file(s). Converting..."

SUCCESS=0
FAIL=0
CURRENT=0

for f in "${FILES[@]}"; do
    CURRENT=$(( CURRENT + 1 ))
    base=$(basename "${f%.*}")
    out="${base}.jpg"

    echo "    [$CURRENT/${#FILES[@]}] $base.HEIC → $out"

    if heif-convert "$f" "$out"; then
        mv "$out" JPEG/
        (( SUCCESS++ ))
    else
        echo "    [!] Failed: $f"
        (( FAIL++ ))
    fi
done

# ── 4. chmod 777 recursively on JPEG folder ─────────────────
chmod -R 777 JPEG

echo ""
echo "[✓] Done! $SUCCESS converted, $FAIL failed."
echo "[✓] JPGs are in: $(pwd)/JPEG"

Older Script Which Might Work

#!/bin/bash
# init
function pause()
{
   read -p “$*”
}
 
 
sudo apt install libheif-examples -y
echo ""
echo "---------------------------------------------"
echo " Convert HEIC to JPEG                        "
echo "----------------------------- ---------------"
echo ""
echo "Enter the path where HEIC files are stored: "
echo "       eg: /home/username/HEIC              "
echo ""
echo "$path"
read path
echo ""

echo "Press any key to continue......."
echo ""
cd $path

for file in *.HEIC; do heif-convert $file ${file/%.HEIC/.jpg}; done

mkdir HEIC_FILES
mv *.HEIC HEIC_FILES

mkdir MOV

mv *.MOV MOV
mkdir JPEG

mv *.JPG JPEG
mv *jpg JPEG
chmod -R 777 JPEG

mkdir PNG

mv *.png *.PNG PNG

chmod -R 777 *

By admin