Kiwi Avatar

Compact Bash pattern wip

Forked from Compact Bash pattern

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