April 22, 2022    Share on: Twitter | Facebook | HackerNews | Reddit

Change extension for multiple files in Zsh

In Zsh it is 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 comming from from: unix.stackexchange. Credits to: Gilles ‘SO- stop being evil’



Tags:  zsh shell zmv