Convert .wav to .mp3 and set id3 tags
Today, I've been listening to a set on Soundcloud that only provides .wav
downloads. I wanted to save a copy so that I can sync it to my phone for when I don't have internet connectivity. The first thing to do, was to download all the tracks as .wav
. I did this by clicking download next to each song in the set
Once I had all the songs, it was time to convert them to .mp3
and set their metadata. First, we need to grab a couple of dependencies.
bash
sudo apt-get install lame mp3info
First, convert from .wav
to .mp3
. We make high quality files (-V 1) and use the default bitrate (128kbps)
bash
for f in *.wav; do lame -V 1 "$f" "${f%.wav}.mp3"; done
Once we have our .mp3
files, we need to set our metadata. This is fairly straightforward use of the mp3info
utility. A nice little trick is that we set the song title to be the same as the filename, minus ".mp3" by using ${i%.mp3}
.
bash
# `-t` is the song title# `-l` is the album# `-a` is the artist# `-g` is the genre number (See http://axon.cs.byu.edu/~adam/gatheredinfo/organizedtables/musicgenrelist.php)for i in *.mp3; do mp3info -t "${i%.mp3}" -l "2014 World Championships" -a "League of Legends" -y "2014" -g 36 "$i"; done
Job done. I downloaded an album as .wav
, converted to .mp3
and set all the metadata all on the command line.