How to convert CD to mp3 command line linux

These days it isn’t very often I have a need to load a CD anymore. But occasionally I will end up with a new CD for one reason or another that needs to be converted to something I can load onto my phone. Here is my quick method for a command line way to convert an audio CD to mp3s.

This is a two step process


  • Linux with a bash shell
  • Have cdparanoia installed. $ sudo apt install cdparanoia
  • First Step: Convert the CD to WAV files using cdparanoia

    [ mrharmon: ~ ]$ cdparanoia -B

    You should end up with some output as follows:

    cdparanoia III release 10.2 (September 11, 2008)
    Ripping from sector       0 (track  1 [0:00.00])
    	  to sector  232720 (track  7 [6:42.02])
    outputting to track01.cdda.wav
     (== PROGRESS == [                              | 031681 00 ] == :^D * ==)   
    outputting to track02.cdda.wav

    Second Step: Convert the WAV files to MP3 using lame

    what we will do here is execute a simple bash loop that will find all wav files in the folder and iterate on converting them to mp3 via the lame tool.

    $ for file in *.wav; do lame $file; done

    Now you should have your output files in mp3 format. At this point you can delete the wav files since they are no longer needed.

    There are a lot of possibilities for the above tools (lame and cdparanoia). I recommend reading the man pages if you want to encode files with more advanced options such as different bit rates, file formats etc.