Recoding files to Ogg Vorbis using gst-launch in a shell script

Here is a stupid, small but working recode script. It recodes flac, mpc, mp3 and m4a to Ogg Vorbis using gstreamer, after recoding the files are placed in the 'old' directory. Really simple, but if you have a large collection of mp3 files you want to recode into low quality Ogg Vorbis files, here is one way to do it.

#!/bin/sh
mkdir -p old
rename 's/\.[Ff][Ll][Aa][Cc]$/\.flac/' *
rename 's/\.[Mm][Pp][Cc]$/\.mpc/' *
rename 's/\.[Mm][Pp]3$/\.mp3/' *
rename 's/\.[Mm]4[Aa]$/\.m4a/' *
chmod u+rw *.mpc *.mp3 *.flac *.m4a
chmod a-x *.mpc *.mp3 *.flac *.m4a

for file in *.mpc;do
echo
echo Processing: $file
  gst-launch filesrc location="$file" ! decodebin ! vorbisenc quality=0.2 ! oggmux ! filesink location="`basename "$file" .mpc`".oga && mv "$file" old
done

for file in *.mp3;do
echo
echo Processing: $file
  gst-launch filesrc location="$file" ! mad ! audioconvert ! vorbisenc quality=0.2 ! oggmux ! filesink location="`basename "$file" .mp3`".oga && mv "$file" old
done

for file in *.flac;do
echo
echo Processing: $file
  gst-launch filesrc location="$file" ! flacdec ! audioconvert ! vorbisenc quality=0.2 ! oggmux ! filesink location="`basename "$file" .flac`".oga && mv "$file" old
done

for file in *.m4a;do
echo
echo Processing: $file
  gst-launch filesrc location="$file" ! decodebin ! audioconvert ! vorbisenc quality=0.2 ! oggmux ! filesink location="`basename "$file" .m4a`".oga && mv "$file" old
done