Results 1 to 10 of 10

Thread: Howto: mp3 to wav script

  1. #1
    Join Date
    Mar 2006
    Beans
    336

    Howto: mp3 to wav script

    I'm sure there is something out there that does this already but I make a lot of CDs and because of this a needed a very quick method for batch converting .mp3 files to .wavs, to be burned to CDR.

    This script will loop through all the files in the folder you specify and convert them from .mp3 to .wav

    copy the following code and save it in a file mp32wav.sh

    Code:
    #!/bin/bash
    #Script: mp32wav script (requires mpg123 package)
    #Purpose: Loops through a path and convert all the mp3s to wavs
    #
    #usage: mp32wav [Path]
    
    count=0
    
    Convert(){
    mpg123 -b 10000 -s "$x" | sox -t raw -r 44100 -s -w -c2 - "`sed s/mp3/wav/ sedEdit`"
    }
    
    syntax_error(){
    clear
    echo "Mp32Wav - Convert Mp3 Files To Wav Files"
    echo "script syntax: mp32Wav <path>"
    echo ""
    exit 0
    }
    
    if [ -n "$1" ]; then
       cd "$1"
       for x in *.mp3
    	do
    	let "count += 1"
              echo "$x" > sedEdit
    	  Convert
    	done
    else
    	syntax_error
    fi
    echo "$count mp3s found and converted to wavs... [Baileysoft 2005]"
    rm sedEdit
    exit 0
    1. install mpg123
    Code:
    sudo apt-get -y install mpg123
    2. make the file executable
    Code:
    chmod +x mp32wav.sh
    3. copy to /usr/bin
    Code:
    sudo cp mp32wav.sh /usr/bin/mp32wav
    Usage:
    mp32wav <path>

    example: mp32wav /tmp/mp3
    Converts all the mp3s in /tmp/mp3 to wavs

    example: mp32wav `pwd`
    converts all mp3s in your current directory to wavs

  2. #2
    Join Date
    Jun 2006
    Location
    Texas, USA
    Beans
    59
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Howto: mp3 to wav script

    wow, thanks man, that's pretty cool. I usually make mp3 cd's because of my cd player in car can handle mp3's but that's great. Now i can use the normal cd writer for when i need to make real cd's. Thanks. And could i get permission to offer thie bash file on my site with your name and webaddress/email with it? Thanks. Keep up the awesome work.

  3. #3
    Join Date
    Jul 2005
    Location
    CT, USA
    Beans
    107
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Howto: mp3 to wav script

    Hi,

    There is an app called audio-convert, which I think does similar things please see http://www.ubuntuforums.org/showthre...=audio-convert

    Chajuram.
    AMD Athlon 2800+
    My Home
    My New Page

  4. #4
    Join Date
    Mar 2006
    Beans
    336

    Re: Howto: mp3 to wav script

    @gorilla_king,

    Feel free to use it however you want, and/or improve on it. I was thinking of adding a segment in it as well to call cdrecord as well so it would convert the files and burn them automatically.

    @chajuram,

    As I said in the article, I'm sure there are a ton of ways to acheive this. I just wanted something small, simple, and fast.


    I find myself, making CDs all the time so for me the easiest way is to copy the mp3s into a specific folder (albumName) and run the script against the folder. In a matter of seconds I have wav files ready to be burned to traditional CDs (the ones that will play in any car).

  5. #5
    Join Date
    Jun 2006
    Location
    Texas, USA
    Beans
    59
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Howto: mp3 to wav script

    Quote Originally Posted by Thund3rstruck View Post
    @gorilla_king,

    Feel free to use it however you want, and/or improve on it. I was thinking of adding a segment in it as well to call cdrecord as well so it would convert the files and burn them automatically.
    Alright i'll add it later, thank you.

  6. #6
    Join Date
    Jun 2006
    Beans
    Hidden!

    Re: Howto: mp3 to wav script

    Hey, thanks for this nice 'How to' I followed all the steps and everything seems to be ok, but when I executed the script said;
    /usr/bin/mp32wav: line 10: sox: command not found
    Could you please tell me what should I do now?

  7. #7
    Join Date
    Jul 2006
    Beans
    8

    Re: Howto: mp3 to wav script

    Sox is a program that translates sound files
    from one type to another.

    Just type:

    Code:
    sudo apt-get install sox
    and you will install sox.

  8. #8
    Join Date
    Jun 2006
    Beans
    Hidden!

    Re: Howto: mp3 to wav script

    'agc' thank you so much, now it is working like a charm.

  9. #9
    Join Date
    Feb 2009
    Beans
    2

    Re: Howto: mp3 to wav script

    hallo @ all

    I use K3b on Ubuntu 8.10
    i installt

    apt-get install libk3b3-extracodecs

    and?
    it works

    g.
    richy

    www.colourful-leaves.de

  10. #10
    Join Date
    Jan 2008
    Beans
    5

    Re: Howto: mp3 to wav script

    Ancient thread, but this is still a top google hit so therefore:

    On any recent ubuntu version, there is a simple add-in for sox that does this in a completely painless way. Simply add libsox-fmt-mp3 to your installed packages via Aptitude or whatever you use. Or, in a terminal, type:

    sudo apt-get install libsox-fmt-mp3


    Best,
    Dirk

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •