Skip to content

Instantly share code, notes, and snippets.

@gentam
Last active December 31, 2017 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gentam/b0836fc582a8578d578277b859f3bae9 to your computer and use it in GitHub Desktop.
Save gentam/b0836fc582a8578d578277b859f3bae9 to your computer and use it in GitHub Desktop.
bulk extension name change
#!/usr/bin/env bash
if [ $# -ne 2 ]; then
echo "Usage: $(basename $0) oldExt newExt
e.g. $(basename $0) JPEG jpg"
exit 1
fi
oldExt=$1
newExt=$2
for file in *.$oldExt; do
newName=${file%.$oldExt}.$newExt
mv -i "${file}" "${newName}"
echo $newName
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment