Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Originally posted by jharris I have a feelin' (but no 100% sure) that mpg123 will do this for you (from the command line), have a look at http://www.mpg123.org/
HTH
Jamie...
Code:
mpg123 -v -w outfile.wav infile.mp3
The -v option shows the conversion stats, the -w tells it to write output to a file named outfile.wav. I did a bunch of this last weekend.
<sits back and waits for the cdburner questions...>
I am trying to write a script to make it much less time consuming to convert mp3's to wav using mpg123. I would like to throw a bunch of mp3's into a folder and execute this script to convert all of the mp3's to wav's and throw the converted wav's into a folder called wav.
So for example: If my folder contained the following mp3's in it: x.mp3, xx.mp3, xxx.mp3 My script will iterate through something Like this: mpg123 -v -w ./wav/1.wav x.mp3;mpg123 -v -w ./wav/2.wav xx.mp3; mpg123 -v -w ./wav/3.wav xxx.mp3; .
I think I will somehow have to take the output of ls and input that into my for loop but Im not sure how to do that.
Does anyone out there know how I should script this? I am very new to linux shell scripting however I've wanted to learn it for along time and this is a good practice for me .
I was on Tucows and found several Windows software packages that convert WMA to MP3 that if you can transfer your WMAs to a Windows box, convert them and then move them back to your linux workstation, you can continue burning your newer disks to your Linux box to save some time and energy converting WMA to WAV and then WAV to MP3. Doing the long way on your linux box hoardes VALUABLE DISK SPACE and MIGHT be simpler in the long run. Attempt to burn the files on to CD-R or CD-RW and then more disks on the way back.
I know, I know, tisk tisk to me for moving data to a windows box, but it may save you time and disk space.
I wanted to let you all know that I wrote a very simple script so that you can put all the mp3's, . .mpg's you want to convert to wav in a folder and convert them all to wav.
I am going to imporve this script some more, as its very simple right now, I call this script conv:
#!/bin/bash
for X in *m*
do
mpg123 -v -w "${X}.wav" "$X"
done
rm *.mp3 *.mpg;
It works for all mp3's and mpg's or any other file type you wanted. Eventually I would like to let the user input what type of file they are converting, and what type of file they want to convert to. For instance if the user wanted to convert wav to mp3 instead. I would also like to let the user choose files he, she wants to convert. Maybe I'll use ncurses for this. If anyone would like to help me with this please let me know, thanks,
I was just reading aliens bash tuitorial(http://subsignal.org/doc/AliensBashTutorial.html) and was just beginning to experiment with sed and ncurses. I find this very very helpful and you just made it easier for me to see how to do this. I meant to have *.m* before. Sorry for the mistake . Thanks for the pointers.
How could I extend this so that it uses a menu system(preferably Ncurses)? I want to make it so that the user can pick his/her files he would like to convert, and then pick what to convert them to. Then he should be able to choose the output directory etc..
I encountered a slight problem with the revised script now. The problem is on this line:
x=`echo ${i} | sed -e 's/mp3/wav/'`
This will not allow me to convert mpg files at the same time as mp3 files. I tried this:
x=`echo ${i} | sed -e 's/mp3/wav' || sed -e 's/mpg/wav'`
but that didnt seem to work either.
How can I make sed perform the same operation on both mpg files and mp3 files? As it is now, it can only do either mp3 or mpg, but not both. I tried this also with no luck:
for i in {*.mp3,*.mpg}
do
x=`echo ${i} | sed -e 's/mp3/wav/'`
y=`echo ${i} | sed -e 's/mpg/wav'`
mpg123 -v -w "${x}" "${i}"
mpg123 -v -w "${y}" "${i}"
done
rm *.mp3 *.mpg
I think I need some type of if statement here but Im not exactly sure where to go with it. Any help would be apreciated, thanks,
#!/bin/bash
for i in *.mp3
do
x=`echo ${i} | sed -e 's/mp3/wav/'`
mpg123 -v -w "${x}" "${i}"
done
for i in *.mpg
do
x=`echo ${i} | sed -e 's/mpg/wav/'`
mpg123 -v -w "${x}" "${i}"
done
I have never used an mpg file so I didn't think about that, sorry....
I'd suggest also taking a look at Audacity. I can't help with conversion scripts that operate on multiple files, but if it's a simple format conversion, Audacity is very cool. -- J.W.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.