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 in bash.


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

Then I made is executable from the command line.

chmod +x

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