I had an old script that was fairly barebones and which does not preserve metadata. I have a newer script which includes the ability to use the directory path and which preserves metadata. Frankly, there’s no reason to use the older script and it’s here for archival purposes….of some kind.

Old Script

#!/bin/bash
sudo apt-get install lame -y
cd /home/guy/Desktop/197*
mkdir MP3
LAMEOPTS="-S"

for FILE in *.flac ; do
    OUTNAME=`basename "$FILE" .flac`.mp3
    lame $LAMEOPTS "$FILE" "$OUTNAME"
done
mv *mp3 MP3
chmod -R 777 *
exit

New Script

#!/bin/bash
# init
function pause()
{
   read -p “$*”
}
echo ""
echo "---------------------------------------------"
echo " Convert FLAC to MP3 Saving Metadata         "
echo " Enter the path the your FLAC folder, below: "
echo "----------------------------- ---------------"
echo ""
echo "eg: /home/username/Desktop/FLAC               "
echo ""
echo "$path"
read path
echo ""

read -p "Press a key to convert your files to .mp3"
cd $path
mkdir MP3

find . -name "*.flac" -exec ffmpeg -i {} -ab 160k -map_metadata 0 -id3v2_version 3 {}.mp3 \;

mv *mp3 MP3
chmod -R 777 *
exit

By admin