Skip to content

Instantly share code, notes, and snippets.

@jasondmoss
Last active December 27, 2015 17:49
Show Gist options
  • Save jasondmoss/7365601 to your computer and use it in GitHub Desktop.
Save jasondmoss/7365601 to your computer and use it in GitHub Desktop.
Bash: Rename the extensions of a group of files in a directory.
###
## Rename file extensions
##
## EG. renameExt old new
###
function renameExt() {
for file in *.$1
do
mv -- "$file" "$(expr "$file" : '\(.*\)\.'$1).$2"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment