Converting FLAC to ALAC on macOS

I’ve been looking for a way to batch convert FLAC files to ALAC (Apple Lossless) format easily on my Mac. I finally found a solution that does what I want: convert the file with equivalent quality and preserve metadata so I can drop the file right into the macOS Music app and play it.