Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just discovered zmv this morning.

To test it i have created a few files.

test1.txt test2.txt test3.txt

I'm trying to rename them with zmv I'd like to get this output:

test-1.txt test-2.txt test-3.txt

when I try to use wildcards I get an error message:

zmv '(*)([0-9]{1,})(.txt)' '$1-$2$3'
zmv: error: number of wildcards in each pattern must match

Am i doing something wrong (answer has to be yes :) )

share|improve this question
If the first parameter is a regular expression and it is greedy by default, try ([^0-9]*) as the first part maybe. –  Oliver Salzburg Mar 14 '12 at 12:04
What zsh version? Do you have zmv aliased? –  Gilles Mar 14 '12 at 22:38
zsh 4.3.9, autoload -U zmv, alias zmv="noglob zmv -W" –  Yannick Schall Mar 14 '12 at 23:26

1 Answer 1

Do you only want to add a - to the filename? Try it like this:

zmv -n 'test(*).txt' 'test-${1}.txt'

The -n switch shows you what would happen without really performing any action.

share|improve this answer
Tried just that, but I get the same error message. I'm running zsh 4.3.9 on osx. not sure if it changes anything. –  Yannick Schall Mar 14 '12 at 12:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.