Skip to content

Instantly share code, notes, and snippets.

@wsoyka
Created March 15, 2019 11:43
Show Gist options
  • Save wsoyka/dd98c19cf806667c07c50cca37db3423 to your computer and use it in GitHub Desktop.
Save wsoyka/dd98c19cf806667c07c50cca37db3423 to your computer and use it in GitHub Desktop.
Rename all files extensions to lowercase with zsh, ignoring directories.
Rename all files extensions to lowercase with zsh, ignoring directories.
#load zmv
autoload -U zmv
zmv -Qvn '(**/)(*).(*)(.D)' '$1$2.${(L)3}'
Whats happening here:
-Q enable globs (for directory matching later on)
-vn verbose output, no executuion - remove these after checking this command does what you want it to
(**/) go through all subdirectories, target saved in $1
(*).(*) filename up to last point - $2 '.' filextension after last point - $3
(.D) ignore directories
${(L)3} make $3 lowercase
Since $3 will only target stuff after the last dot, this wont work for double extenstions like .TAR.GZ (would become .TAR.gz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment