# Zmv ## Metadata **Status**:: #x **Zettel**:: #zettel/literature **Created**:: [[2023-07-01]] **Tags**:: #command-line #zsh **Parent**:: [[Zsh]] ## Synopsis Zmv is a [[Zsh]] utility to rename files in batch. See also [rnr](https://github.com/ismaelgv/rnr). ## Enable ``` autoload -U zmv ``` ## Usage ``` zmv [ -finqQsvwW ] [ -C | -L | -M | -{p|P} program ] [ -o optstring ] srcpat dest Move (usually, rename) files matching the pattern srcpat to corresponding files having names of the form given by dest, where srcpat contains parentheses surrounding patterns which will be replaced in turn by $1, $2, ... in dest. ``` See `man zshcontrib` ### Manual ``` man zshcontrib ``` ## Cheatsheet ``` shell # Rename foo.txt to foo.md zmv '(*).txt' '$1.md' # Replace every space by an underscore zmv -v '(* *)' '${1// /_}' zmv -v '* *' '${f// /_}' # Remove digits prefix zmv -v '[[:digit:]]##(*)' '$1' ``` Zmv uses [[Zsh Extended Glob|Extended Glob]] in the pattern.