$ mv path/to/{orig,dest}.foo
# expands into
$ mv path/to/orig.foo path/to/dest.foo $ mv path/to/{orig,dest}.foo
# expands into
$ mv path/to/orig.foo path/to/dest.fooYou could, for instance, rename by regular expressions, easily do block selections and substitutions, use complex macros, etc. The sky is really the limit.
Then there are unlimited undo features of modern editors, and even branching undo histories where you can get back to a state that would be unreachable with linear undos.
Finally, tools like qmv do sanity checking on your renaming plan, so that if you (for example) wind up renaming two files to the same name, it'll warn you and safely let you rename the original files and try again.
As a result of the power and safety these tools provide, I no longer rename directly using my shell's renaming features (like the ones you describe) except for the absolute simplest and foolproof situations. For anything more complex, I use qmv.
I can certainly recognize the power of what you are describing. Perhaps I'll give it a try in the future.
Out of curiosity: what do you find are your most compelling use cases for the tool(s)?
autoload -U zmv # or put this line in your ~/.zshrc
zmv -w 'src/**/*.jade' 'src/$1$2.pug'
You can do a dry run by using the `-n` flag too. for a in **/*.jade; do echo mv "$a" "${a%jade}pug"; done
If I'm not wrong it should work in Bash and Ksh too (bar the double * expansion), this when I don't have an Emacs at hand.In the first invocation I prefer to do a "dry run", if it looks good I proceed removing the echo.
P.S. Your example above should use double quote instead of single quote, otherwise the content is not expanded by Zsh
P.P.S. One recall the pre/post operator looking at the symbols on a US keyboard, the post follows the variable symbol...
I've used zmv to also reorganize the directory structure of files too, something that seems easier to do with its glob/variable replace syntax.
Nice to have a cross platform option for usage in scripts though.