Linux rename a bunch of file's extensions


In order to rename a whole folders file extensions from jpeg to jpg I wrote this script called rename.sh in bash.

#!/bin/bash

for filename in *.jpeg
do
echo \$filename;
cleaned=`basename \$filename .jpeg`;
echo \$cleaned;
mv \$filename \$cleaned.jpg;
done

Then I made is executable from the command line.

chmod +x rename.sh

Then ran it in the directory I needed to rename files in.

./rename.sh