LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   quick shellscript (https://www.linuxquestions.org/questions/linux-newbie-8/quick-shellscript-738830/)

icecubeflower 07-09-2009 03:08 AM

quick shellscript
 
Anybody know shellscripts?

Suppose this converts an mp3 to a wav:
mpg123 -w song.wav song.mp3

Can anybody write me a little shellscript to convert all mp3's in the same directory as the shellscript to wav's?

I still never learned shellscripts. Probably I should get around to that someday.

i92guboj 07-09-2009 03:14 AM

You don't need much scripting for that. I am not familiar with mpg123, but the general idea if you use bash as your shell would be this:

Code:

for file in *.mp3; do lame --decode "$file" "${file/.mp3/.wav}"; done
Change "lame --decode" by whatever you want. I prefer to use lame just because I am familiar with it.

vonbiber 07-09-2009 08:27 AM

Quote:

Originally Posted by icecubeflower (Post 3601896)
Anybody know shellscripts?

Suppose this converts an mp3 to a wav:
mpg123 -w song.wav song.mp3

Can anybody write me a little shellscript to convert all mp3's in the same directory as the shellscript to wav's?

or you could also

for file in *.mp3
do
lame --decode "$file" "${file%.*}.wav"
done

pixellany 07-09-2009 08:43 AM

Quote:

Originally Posted by icecubeflower (Post 3601896)
I still never learned shellscripts. Probably I should get around to that someday.

Indeed!! Eventually you will find that writing your own is more efficient than trying to persuade others to do it for you.

I would start with the "Bash Guide for Beginners" by Machtelt Garrels. Free at http://tldp.org


All times are GMT -5. The time now is 11:45 AM.