zmv naming files
As well known,
zmvis one of the goodies that come for free when using the great zsh shell, and it allows for a fast and easy way to bulk renaming files using a pattern like syntax. As of today, I did not need to number renamed files, but of course the
zmvprovides a quick way to do it. In fact,
zmvallows for shell interpolation within the command itself, so that for instance:
does the trick! The idea is simple: the
% counter=1 zmv '*.jpg' 'foo-$((counter++)).jpg'
countervariable is incremented each tiem
zmvrequires a new evaluation of the name, and this is done via the
$(( ))arithmetic expansion.