LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-09-2009, 03:08 AM   #1
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 313

Rep: Reputation: 34
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.
 
Old 07-09-2009, 03:14 AM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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.
 
Old 07-09-2009, 08:27 AM   #3
vonbiber
Member
 
Registered: Apr 2009
Distribution: slackware 14.1 64-bit, slackware 14.2 64-bit, SystemRescueCD
Posts: 533

Rep: Reputation: 129Reputation: 129
Quote:
Originally Posted by icecubeflower View Post
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
 
Old 07-09-2009, 08:43 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by icecubeflower View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Shellscript paraiso Linux - Newbie 7 05-12-2005 07:25 AM
Lockscreen Shellscript 2 paraiso Linux - General 1 05-11-2005 05:30 PM
shellScript help paraiso Linux - Newbie 2 05-10-2005 07:09 PM
LS and shellscript - I'm stuck MikeHunt79 Linux - Software 2 03-11-2005 04:44 AM
ShellScript sharadgana Programming 1 12-16-2004 01:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration