If it can help ....
I've written a small bash script to do this ....
You need to have ffmpeg / flac installed.
How it works:
It takes 2 arguments :
- The folder of your music library (flac/ogg/mp3 ...)
- The destination folder (you need to create it before).
It produce :
- An exact copy from the source folder into the destination folder, with:
- the non flac files copied into.
- the flac files transformed to mp3 ( VBR high quality)
- A run.sh file with the commands to convert the flac files (this script is executed automatically).
#!/bin/bash
FLAC_PATH=$1
CONV_PATH=$2
DEBUG=0;
function usage {
echo "";
echo " This script convert all flac files from a folder to mp3 files to a second folder";
echo "";
echo " Usage :";
echo " ./conv.sh {Source Folder} {Destination Folder}";
echo " note : booth folder must exist before starting this script";
echo " files other than flac are copied to the destination folder";
echo "";
}
if [ ! -d "$2" ]; then
echo "";
echo " ERROR : [$2] is not a directory.";
usage
exit 1
fi;
if [ ! -d "$2" ]; then
echo "";
echo " ERROR : [$2] is not a directory.";
usage
exit 1
fi;
COMMANDS="run.sh"
echo "" > run.sh
echo " convert from $FLAC_PATH to $CONV_PATH ";
find "${FLAC_PATH}" -type f |while read myFile; do
SRC_DIR=${myFile%/*}
SRC_FILE=${myFile##*/}
DST_DIR=$CONV_PATH/$SRC_DIR
mkdir -p "${DST_DIR}"
# TEST if the file is a flac ....
metaflac --show-md5sum "${myFile}" 2>/dev/null 1>/dev/null
if [ $? -eq 0 ]; then
echo -n " *** $myFile [FLAC !] : "
DST_FILE=${myFile%.*}
OUT_PATH="${DST_DIR}/$( echo $SRC_FILE | sed -e 's/.flac$/.mp3/')"
if [ $DEBUG == 1 ]; then
echo " SRC = $myFile";
echo " OUT = $OUT_PATH"
fi;
if [ -f "$OUT_PATH" ]; then
echo " exist, do nothing !";
else
echo " add to compress list !";
echo "ffmpeg -y -i \"${myFile}\" -codec:a libmp3lame -q:a 0 -map_metadata 0 -id3v2_version 3 \"${OUT_PATH}\" " >> $COMMANDS
fi;
else
echo -n " *** $SRC_FILE [NOT FLAC] : "
if [ -f "${CONV_PATH}/${myFile}" ]; then
echo " exist, do nothing !"
else
echo " copy."
cp "${myFile}" "${CONV_PATH}/${myFile}"
fi
fi
done;
echo " And now, CONVERT THE FLAC's!!! "
sh run.sh