Computing.Net > Forums > Linux > Shell scripting help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Shell scripting help

Reply to Message Icon

Name: Hiran
Date: April 12, 2003 at 14:22:25 Pacific
OS: Debian
CPU/Ram: AMD 900/128MB
Comment:

I'm trying to write a script to batch convert wavs to mp3s. So far I have this:

for file in `ls [Directory]` ; do
lame -b 320 -q 0 $file.wav $file.mp3
done

But the problem seems to be that even though ls lists the full file name (w/ spaces and all), each name is being broken up with space as the token (I tried an echo $file to confirm this). I was thinking I could concatenate $file with some temp variable and then when $file has a ".wav" in it, do the conversion and then reinitialize the variable. If so, how do I check the last four characters of $file? Or is there a better way to do this? Thanks.

God bless
Hiran



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: April 12, 2003 at 20:58:25 Pacific
Reply:

The rename command would be a big help to you if you want to remove spaces from file names.


0

Response Number 2
Name: danco
Date: April 13, 2003 at 11:04:40 Pacific
Reply:


Hiran, I'm trying to do exactly this same thing -- did you find a simple solution yet? I found autolame and some other tools at http://www.mp3-converter.com/linux/ but I was hoping to find a simple script just like you have above. If you find a simple scripting solution, please let me know.


0

Response Number 3
Name: ramadog
Date: April 13, 2003 at 18:54:39 Pacific
Reply:

Something like this should work

#!/bin/bash

for i in *.wav
do
NAME=`basename "$i" .wav`
lame "$NAME".wav "$NAME".mp3
done


0

Response Number 4
Name: danco
Date: April 13, 2003 at 20:50:38 Pacific
Reply:


Great, thank you.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Patched kernel with bindi... Getting rid of Fat32 w/ p...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Shell scripting help

advanced shell script help www.computing.net/answers/linux/advanced-shell-script-help/17749.html

shell script help www.computing.net/answers/linux/shell-script-help/15420.html

begginner shell script help ASAP! www.computing.net/answers/linux/begginner-shell-script-help-asap/18683.html