How can I convert an iTunes WAV music library to FLAC from the command line?

I have a large music library that is currently managed by iTunes in Windows. When I started out 5 or 6 years ago ripping my music to my PCs I had a fairly basic understanding of audio formats, and I somewhat arbitrarily chose to rip all my CDs into the WAV format. So now I have over 1 TB of music ripped in iTunes, and none of my files have metadata attached. (iTunes software stores the artist/song/etc. info in an XML file, so I have a reference, and the library is fine, works great in iTunes/Windows).

I've been using Ubuntu exclusively for almost a year now, and I want to convert my music library, which is currently spread out over 3 hard drives, to FLAC files w/ metadata, and move away from iTunes.

What's the most reliable/efficient way to convert all my WAV files across the hard drives to FLAC from the command line while retaining/adding metadata to the new FLAC files? There are just too many files to go through one album at a time. Is there any audio fingerprinting software out there that could find the metadata after the WAV > FLAC conversion? Should I try and reference the iTunes XML file or is that not necessary?


Solution 1:

To simply convert files from Windows WAV to FLAC on the commandline the official tool flac Install flac would be the obvious choice.

flac ~/Music/*.wav

would convert all WAV files from the Music directory in your HOME to flac. By using the option:

flac --keep-foreign-metadata ~/Music/*.wav

even non-flac metadata will be preserved in your resulting *.flac file. However if - as you say - your files are not tagged there is not an easy way to achieve correct metatags. Some tools like metaflac from the flac package can import metatags from file but these files need to meet specific criteria for appropriate tag recognition involving conversion of your XML file.

Therefore I would rather recommend one of the graphical solutions like Ex Falso Install exfalso or Musicbrainz Picard Install picard that offer the creation of metatags from filenames (in case they are appropriate).

Picard also has a tool to auto-recognize a not tagged song to look it up in the Musicbrainz library and create appropriate metatags.

Before playing around with tags it is strongly recommended to backup your original files in case something goes wrong. I speak of own experience when tagging of multiple files resulted in entirely wrong and bad tags that led to almost unretrievable originals as these files were listed with a (random) wrong name in my library.

Solution 2:

Have not tried this myself as my music collection was built in Ubuntu, there is a good guide in link below that covers the cmd line conversion and editing appending of tags

http://www.tuxarena.com/static/cli_audio_guide.php