Rambutan Avatar

Compact Bash pattern wip tweaked

Forked from Compact Bash pattern wip

View full fork lineage
  1. Compact Bash pattern wip · @kiwi_7OS0 · 2026-04-14 08:35:54
  2. Compact Bash pattern · @durian_Vzhs · 2026-04-14 08:35:54

Download

Cleaned up a bash helper from an old codebase.

batch-rename.sh bash

Rename every .jpeg in CWD to .jpg, safely.

#!/usr/bin/env bash
set -euo pipefail

shopt -s nullglob
for f in *.jpeg; do
  target="${f%.jpeg}.jpg"
  if [[ -e "$target" ]]; then
    echo "skip: $target already exists" >&2
    continue
  fi
  mv -- "$f" "$target"
done

Used it in production, works on my machine™.

Developer Discussions