#!/bin/bash
sourcedirectory="/home/marzena/.kde/share/apps/amarok/podcasts/"
targetdirectory="/var/www/jeltsch.org/podcasts/"

for i in $( ls $sourcedirectory*.mp3 ); do
  infn=$i
  echo "Infile = "$infn
  strippedinfn=`basename $i`
  strippedinfn=${strippedinfn//:/}
  echo "Stripped Infile = "$strippedinfn
  outfn="$targetdirectory${strippedinfn%%.mp3}_LQ.mp3"
  echo "Outfile = "$outfn
  if test ! -f $outfn
    then
    echo "Downsampling $outfn."
    lame --mp3input -V 3 --strictly-enforce-ISO --resample 12 $infn $outfn
  else
    echo "The file $outfn has been already downsampled. Skipping..."
  fi
done

