I’m always trying to remember this.

N=0;for i in *.jpg; do mv "$i" "$N".jpg; N=$[$N+1]; done