CentOS - Convert Each WAV File to MP3/OGG

Posted by Benny on Stack Overflow See other posts from Stack Overflow or by Benny
Published on 2010-04-23T13:39:22Z Indexed on 2010/04/23 13:43 UTC
Read the original article Hit count: 461

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about linux

Related posts about scripting