Browse files

zmv + mmv for crazy easy renaming

  zmv [OPTIONS] oldpattern newpattern
where oldpattern contains parenthesis surrounding patterns which will
be replaced in turn by $1, $2, ... in newpattern.  For example,
  zmv '(*).lis' '$1.txt'
renames 'foo.lis' to 'foo.txt', 'my.old.stuff.lis' to 'my.old.stuff.txt',
and so on.  Something simpler (for basic commands) is the -W option:
  zmv -W '*.lis' '*.txt'
This does the same thing as the first command, but with automatic conversion
of the wildcards into the appropriate syntax.  If you combine this with
noglob, you don't even need to quote the arguments.  For example,
  alias mmv='noglob zmv -W'
  mmv *.c.orig orig/*.c
  • Loading branch information...
1 parent bca1f3d commit 42a7276999bc3ce690830c018e5d7cc36ed32f0b @pengwynn committed Jul 19, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 zsh/aliases.zsh
@@ -35,3 +35,9 @@ alias showdesktop="defaults write CreateDesktop -bool true && k
# color aliases
alias grcurl="colourify curl -s"
+# zmv ftw
+autoload -U zmv
+# alias for zmv for no quotes
+# mmv *.c.orig orig/*.c
+alias mmv='noglob zmv -W'

0 comments on commit 42a7276

Please sign in to comment.