2022-04-22    Share on: Twitter | Facebook | HackerNews | Reddit

Change Extension for Multiple Files in ZSH

In Zsh it is a bit easier to perform this because of using zmv. First, you need to load zmv. In zsh, run the following command once (or put them in your ~/.zshrc for the future):

autoload -U zmv

change all extensions from .lis to .txt

zmv '(*).lis' '$1.txt'

^*.* means all files except the ones matching *.*, it's a shortcut for *~*.* (both are zsh extensions to the traditional pattern syntax).

for all files set extension .md

zmv '^*.*' '$f.md'

Tip coming from: unix.stackexchange. Credits to: Gilles 'SO- stop being evil'



Tags:  zsh shell zmv