iTunes Automation: Convert FLAC Audio Files to Apple Lossless
Update 07-Jul-2013: My iTunes for Windows automation scripts have got a home page at github.io: http://dmitryleskov.github.io/iTunesScripts/, and the latest release can now always be found at https://github.com/dmitryleskov/iTunesScripts/releases.
If this is not your first visit to my blog, you may recall that I had ripped all my audio CDs and put them away in boxes last year. My music collection now occupies just a tiny corner of a 1.5 TB hard drive. (I do not own THAT many CDs as you may guess.) Not a big deal itself these days, but the reason for blogging about that was the small utility I had then written to help EAC deal with UTF-8 encoded freedb entries. Now time has come to share with you another FLAC tool that I have created for myself. Hope you will find it handy.
Basically, I wanted to use iTunes Remote to control the playback on the PC and occasionally copy some tracks to my iPad. Problem is, iTunes does not support FLAC, so it looked as if I had to use a third-party plugin or a converter. But then I have discovered the iTunes COM for Windows SDK and put together a script that has imported my entire FLAC collection into iTunes in Apple Lossless format in just a few hours. (That’s on an i5 desktop and, mind you, I do not have THAT many CDs, so your mileage will vary.)
The script needs two binaries from the official FLAC command-line tools,
metaflac.exe, and a small helper utility to convert metadata from UTF-8 to UTF-16.
For your convenience, dear reader, I have put together a package containing all those dependencies, but I must first warn you that my solution currently has a few limitations:
- It is not capable of processing albums ripped of downloaded as a single FLAC file. You must split them into individual tracks before conversion.
- The FLAC files that have any of the metatags ARTIST, ALBUM, and TITLE missing are skipped.
- Tracks are imported in Apple Lossless (ALAC) format.
If you need any of these fixed, drop me a line in the comments or fork my script on GitHub – it is available under the MIT/X11 license.
Update 19-Feb-2012: Recorded a screencast for the most straightforward usage scenario.
Update 02-Feb-2013: Fixed a bug with invalid track numbers causing crashes.
Update 15-Jun-2013: Fixed a bug that caused the script to abort after converting a FLAC file with the readonly attribute set. Credit for finding the root cause and suggesting a fix goes to Dave Granic – thank you, Dave!.
Update 14-Jul-2013: Fixed a bug: metadata-less FLAC files caused the script to crash.