Links
- Reference
- Rename/move files matching the
EXTENDED_GLOB
pattern srcpat
to corresponding files having names
of the form given by dest
.
srcpat
contains parentheses surrounding patterns which will be replaced in turn
by $1
, $2
, … in dest
.
- Any error (a substitution results in an empty
string, two substitutions give the same result, the
destination was an existing regular file and
-f
was
not given) causes the entire function to abort
without doing anything.
- -n for a dry run.
- -v for verbose.
- -w to implicitly add parenthesis for all
wildcard patterns in
srcpat
.
- -W
- implicitly add parenthesis for all wildcard
patterns in
srcpat
(i.e. -w
), and
- turn wildcards in
dest
to references like
${1}
, ${2}
, etc.
- -i for an interactive "yes/no" for each rename.
- -C to force cp.
- -M to force mv.
- -L to force ln.
- zmv (zsh wiki),
- Lots of examples
Snippets
# For example, rename all the avi files to replace _ by
# simple spaces, replace '.' by simple spaces lowercase
# the filename, and capitalise the first letter of each
# words :
zmv '(*).avi' '${${(LC)1//./ }//_/ }.avi'
# If you want case insensitivity pattern matching you
# can add (#i) at the begining of the first sentence for
# exemple
#
# All files having for extenstions .avi or .Avi or .AVI
# or etc. will match and will be renamed as previously.
zmv '(#i)(*).avi' '${${(LC)1//./ }//_/ }.avi'