Having decided that I'm better off downloading lossless files from Bandcamp &c., and preferring to save a bit of space by sourcing FLAC files, I finally did something that I should have done a long time ago. The annoying issue for me has always been the extra work necessary in preserving metadata when using a 'flac -d -c input.flac | lame - output.mp3' process. My solution, which works well for me and is being made available here for others, is a simple shell script - flac2mp3.
For those who don't want to read through the script itself, here's how it all goes down. First we check to make sure the user has both flac and lame installed, exit gracefully if either is missing. We probably should check for metaflac, despite it being implied by flac. We should also make sure that metaflac is recent enough to use --show-tags instead of --show-vc-field. Anyway, assuming that we have the necessary tools, we go through every file ending in .flac, and run metaflac a few times to set variables for the title, artist, album, year, and track number. Since the output from metaflac is something like 'ARTIST=Midnight Kids,' we use sed to strip it down to just the content. We use basename to strip out the .flac extension, and then we set a variable for the output name using .mp3 instead. Finally, we pipe flac to lame, using --tt, --ta, &c. to set the tags. We pass the arguments passed to flac2mp3 along to lame - so, we send everything to flac2mp3 just as we would to lame, 'flac2mp3 -h --alt-preset insane,' except ignoring metadata controls and output file.
So, pretty simple, really. If you need more granular control over which files are being processed, &c., then this isn't for you. I just want to bang out a whole directory worth at once, and let it go at that… Anyway the download is up there, or if you don't want to scroll, it's also here.
brian hefele's untidy space