yepegw
Last Updated: February 25, 2016
·
8.295K
· jan0sch
2aaae7041aca85da930bcaf14d6768d2

Mass renaming files with zmv (zsh)

The zsh contains a very usefull extension called zmv. You can load it via autoload -U zmv. The man page is located under zshcontrib. A very usefull flag is -n which does not execute the command but prints the command that would be executed. Use this if you are unsure about your patterns.

Here are two simple examples:

Replace all spaces in filenames with underscores.

zmv '* *' '$f:gs/ /_'

Rename all files according to a pattern.

zmv '*.(*).(*).([0-9][0-9])*.mkv' '$1_$2-$3.mkv'

This one renames all files matching Garbage.Important.Important.Two-Digits-Followed-by-Garbage.mkv into Important_Important-Two-Digits.mkv.

Say Thanks
Respond
Filed Under