CentOS - Convert Each WAV File to MP3/OGG
- by Benny
I am trying to build a script (I'm pretty new to linux scripting) and I can't seem to figure out why I'm not able to run this script. If I keep the header (#!/bin/sh) in, I get the following:
-bash: /tmp/ConvertAndUpdate.sh: /bin/sh^M: bad interpreter: No such file or directory
If I take it out, I get the following:
'tmp/ConvertAndUpdate.sh: line 2: syntax error near unexpected token `do
'tmp/ConvertAndUpdate.sh: line 2: `do
Any ideas? Here is the full script:
#!/bin/sh
for file in *.wav; do
mp3=$(basename .$file. .wav).mp3;
#echo $mp3
nice lame -b 16 -m m -q 9 .resample 8 .$file. .$mp3.;
touch .reference .$file. .$mp3.;
chown apache.apache .$mp3.;
chmod 600 .$mp3.;
rm -f .$file.;
mv .$file. /converted;
sql="UPDATE recordings SET IsReady=1 WHERE Filename='${file%.*}'"
echo $sql | mysql --user=me --password=pasword Recordings
#echo $sql
done