zmv naming files


As well known, zmv is 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 zmv provides a quick way to do it. In fact, zmv allows for shell interpolation within the command itself, so that for instance:
% counter=1 zmv '*.jpg' 'foo-$((counter++)).jpg'
does the trick! The idea is simple: the counter variable is incremented each tiem zmv requires a new evaluation of the name, and this is done via the $(( )) arithmetic expansion.

The article zmv naming files has been posted by Luca Ferrari on November 27, 2017