Bulk renaming files in OSX

OSX comes with a pretty old bash version (3.2 for me). Bash has regex matching using =~ operator. So you could write

f='mylongstring'
[[ $f =~ '(.*)' ]] && echo ${BASH_REMATCH[1]}

and it should return mylongstring. Unfortunately for me it didn’t work. It was echoing an empty string. But regex seems to work as otherwise echo would not execute.

Upgrading bash to a newer version (4.3) didn’t help. I ended up using zmv from ZSH. In order to use it just do

autoload zmv
zmv '(*)_old.jpg' '$1_new.jpg'