[FFMPEG][1] and a simple bash script will get the job done.  FFMPEG is the same set of libraries that are included with products like Handbrake.

The basic syntax is very simple:

    ffmpeg -i inputfile outputfile

If you wanted to convert a FLAC to MP4, you would simply enter

    ffmpeg -i inputfile.FLAC to outputfile.MP4


To convert a number of files a simple bash script like the one below will convert 


    for file in /foo/bar/*.mp3
    do
        fullfilename=$(basename "${file}")
        filename="${fullfilename%.*}"
        ffmpeg -i "$file" "/foo/bar/converted/$filename.mp4"
    done


This basic script parses through a directory, takes the original filename, then removes the extension so a new extension can be added during output.  

  [1]: https://ffmpeg.org/