Systems Administrator by day; ronin illustrator by night. I promote learning the tools in your computer system to complete your work in a more effective way, meanwhile agonizing for hours over an A3 sheet of bristol paper with a 0.03mm pen.


(2022) Really enjoy Krita 5's new feature to record while painting.

Watch me paint this here

View more illustrations

Automatic MP3 from FLAC

Feb 24, 2022

I much prefer lossless audio when listen to music. When listening at home through my PC or home theater I find MP3 leaves something to be desired, unfortunately I do not have the storage space on my cell phone to bring my FLAC collection with me.

While I could rip all my CD’s as both MP3 and FLAC, that leaves downloaded FLAC files to convert, and is considerably time consuming.

The below script is what I use to capture all the music I have, loop through copying non-FLAC audio if they exist, and converting to MP3 if they are FLAC. The mp3 folder synchronizes with my cell phone through Syncthing to bring my music with me for offline enjoyment.

#!/usr/bin/env bash


cd $1
find . -type d -exec mkdir -p -- $mp3dir/{} \;
rsync -avzh --exclude "*.flac" . "$mp3dir/"
for a in ./*/*/*.flac; do
  if [[ ! -f "$mp3dir/${a[@]/%flac/mp3}" ]]
    < /dev/null ffmpeg -i "$a" -qscale:a 0 "$mp3dir/${a[@]/%flac/mp3}"
    echo $mp3dir/${a[@]/%flac/mp3} exists!
echo -e "done."
exit $?

The only applications you need for this script are bash, rsync, and ffmpeg, which should already be installed on your Linux computer.

  • save the script to ./
  • Set the mp3dir (i.e mp3dir=$HOME/SyncMusic)
  • Save
  • chmod +x ./
  • ./ $HOME/Music

If you want to convert your music in batches, put them in $HOME/convert and do ./ $HOME/convert

Per song takes only a few seconds. If you have an exceptionally large music collection this could save you hundreds of hours doing conversions.

If you found this useful please comment below, or float me an email.

Read more