Convert a flac file into an mp3 file

Reading Time: < 1 minuteOn Ubuntu, install flac.

#apt-get install flac lame

Put the following script in /usr/bin/ and give it a name (convert_flac.sh or flac2mp3.sh)

#!/bin/bash  
FLAC=$1
MP3="${FLAC%.flac}.mp3"
[ -r "$FLAC" ] || { echo can not read file \"$FLAC\" >&1 ; exit 1 ; } ;
metaflac --export-tags-to=- "$FLAC" | sed 's/=\(.*\)/="\1"/' >tmp.tmp
cat tmp.tmp
. ./tmp.tmp
rm tmp.tmp

Reading Time: < 1 minute

On Ubuntu, install flac.

#apt-get install flac lame

Put the following script in /usr/bin/ and give it a name (convert_flac.sh or flac2mp3.sh)

#!/bin/bash  
FLAC=$1
MP3="${FLAC%.flac}.mp3"
[ -r "$FLAC" ] || { echo can not read file \"$FLAC\" >&1 ; exit 1 ; } ;
metaflac --export-tags-to=- "$FLAC" | sed 's/=\(.*\)/="\1"/' >tmp.tmp
cat tmp.tmp
. ./tmp.tmp
rm tmp.tmp
flac -dc "$FLAC" | lame --tt "$TITLE" \
--tn "$TrackNumber" \
--tg "$GENRE" \
--ty "$Date" \
--tc "$COMMENT" \
--ta "$ARTIST" \
--tl "$ALBUM" \
--add-id3v2 \
- "$MP3"

change the execution bit

$ chmod 755 /usr/bin/convert_flac.sh

You can run it in a loop

for i in *.flac
do
convert_flac.sh $i
done

By Marc Olivier Meunier

Marc has spent the past few years putting oil on the fire of growth companies. He leads by example and puts a lot of emphasis on inclusion, constantly working to create a safe environment. A warm leader with a passion for memorable experiences and innovation.
Marc is available for contracting as a fractional Head of Customer Experience.
Find Marc on Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *