If you ever need to change at the command line the names of a batch of files consistently, zmv is the tool you’ll want to turn to first. It’s not well known, I thought I’d explore and pass on some notes about taking advantage of it.
It is a function provided by the Z Shell, but it’s not made available by default. To ensure that it is, you need to add this line to your .zshrc file and restart the Terminal.
autoload zmv
The basic structure of a zmv call is zmv 'input_pattern' 'output_pattern'. The patterns are included in single quotes so that they’re not interpreted first by the shell and then passed to the command.
Example
zmv 'photo(*)' 'document $1'
As you might expect, the first pattern finds all files that begin with photo; the rest of the pattern matches against anything. The brackets are standard Z Shell syntax: match the enclosed pattern. zmv passes the result of the match into the output pattern as the variable $1. If you had multiple pairs of brackets, they’d be accessed in the output as $1, $2, $3 etc., in order.
Before committing yourself, you should run the command with the -n switch. This performs a dry run so you can see exactly what the results are going to be. This gets particularly important once you start using complex patterns.
There are many more complex uses for zmv if needed.