Skip to content

Instantly share code, notes, and snippets.

@thetutlage
Created June 30, 2018 05:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thetutlage/a9bb6448eb0ce08163e49ed243b30124 to your computer and use it in GitHub Desktop.
Save thetutlage/a9bb6448eb0ce08163e49ed243b30124 to your computer and use it in GitHub Desktop.
Rename file extensions from a shell script
function rext () {
if [ $# -lt 3 ]; then
echo 1>&2 "$0 needs 3 arguments as DIR SOURCE_EXT DEST_EXT"
else
for file in "$1"/*.$2; do
mv "$file" "${file%.$2}.$3"
done
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment