[Bash] Convert wav to mp3 via ffmpeg


Question

Convert 9dt/9dtXXX.wav to output/9dtXXX.mp3, where XXX are numbers from 000 to 094.

Answer

Install ffmpeg:

# install ffmpeg on Ubuntu Linux 15.10
$ sudo apt-get install ffmpeg

The bash script to convert wav to mp3 via ffmpeg:

#!/bin/bash

OUTPUTDIR="output"

mkdir -p $OUTPUTDIR
for i in {000..094}
do
  ffmpeg -i 9dt/9dt$i.wav $OUTPUTDIR/9dt$i.mp3
done

Save the above bash script as wav2mp3.sh

Run the script by:

$ bash wav2mp3.sh

Tested on Ubuntu Linux 15.10


References:

[1]Google search: linux convert wav to mp3
[2]Converting WAV Files to High Quality MP3 Using Linux terminal - Stack Overflow
[3]Why would I choose Libav over FFmpeg, or is there even a difference? - Super User
[4]software installation - Is FFmpeg missing from the official repositories in 14.04? - Ask Ubuntu