View on GitHub


iTunes for Windows Automation Scripts by Dmitry Leskov

Download this project as a .zip file Download this project as a tar.gz file

This is the home of my iTunes for Windows automation scripts that I share with the world hoping that other people may find them useful.

So far, I have published one script called AddFLACs, which imports FLAC audio files into iTunes in Apple lossless format.

Quick Start: download the latest binary release and watch a screencast of the most straightforward usage scenario.

If it works for you, consider sending me a Gittip. Otherwise, kindly check if it is a known issue before reaching out to me. I am on Twitter as @DmitryLeskov.


26-Aug-2014: Version 1.01 released with a minor bugfix.

17-May-2014: Version 1.0 released. There are now command-line options that enable you to:



AddFLACs - add FLAC files to the iTunes media library


AddFLACs [options] [FOLDER]


The AddFLACs script scans the specified FOLDER and its subfolders for FLAC files, converts them to Apple lossless format and adds to the iTunes library.

To avoid track duplication, AddFLACs first extracts the metadata from each FLAC file it encounters and checks if a track with exactly the same artist, album and title is already present in the iTunes library. Such tracks will be skipped even if they are in a different format.

If FOLDER is not specified, the current folder and its subfolders will be scanned.



Regular expression

-r regular-expression
--regex regular-expression

This option has dual purpose. First, the tracks that do not match regular-expression are skipped. This enables you to filter out tracks that you do not want to import in this session. Second, when there is a match, AddFLACs attempts to substitute the values of the regular-expression capture groups into the values of iTunes fields options (see below). This helps when your FLAC files are not tagged but hierarchically organized on disk. (see EXAMPLES.)

regular-expression is a JavaScript regular expression, matched in case-insensitive mode (native Windows filesystems are case-insensitive.)


-itunes-field-name value

Set itunes-field-name for each track to value. You can specify any valid iTunes field. Note that it is preceded by a single dash. In most cases, you would want to specify several fields, combining them with the --regex option, so as to use capture groups in value (see EXAMPLES.)

If the respective value is also present in the FLAC file metadata, AddFLACs will use it by default, ignoring the command-line option. Use --override-metadata or --ignore-metadata to change this behavior.


Ignore (don't even try to extract) any metadata that may be present in FLAC files. Requires that you specify at least -artist, -album, and -name.


Values specifies on the command line will override the respective fields of existing FLAC metadata.

Other options


Do not actually import tracks into iTunes, only show what would be imported.


Be verbose about what's going on.

-d --debug

Print extra debug information. Useful for debugging regular experessions.



Import all FLAC files from the current drectory and its subdirectories (default).

AddFLACs.bat -n -r ".*\\(.*)\\(.*)\\(.*)\.flac$" -artist "$1" -album "$2" -name "$3"

Import all FLAC files from the current drectory and its subdirectories. Assuming their pathnames match the "Artist\Album\Name.flac" pattern, use the respective capture group instead of missing metadata fields, if any. Do not actually import tracks (re-run without -n after verifying that the fields get extracted as intended.)

AddFLACs.bat --override-metadata ^
  -artist "The Doors" ^
  -sortartist "Doors, The" ^

Import all tracks found under c:\Users\Me\Music\FLAC\Doors, forcing Artist and Sort Artist fields to be set irrespective of what FLAC metadata might contain. Album and track names will still be extracted from metadata (and hence must be present.)


The AddFLACs script and the Unicode conversion helper are released under the MIT/X11 license (see COPYING.MIT.)

The FLAC command-line tools are released under the GPLv2 (see COPYING.GPL.) The source code may be obtained from the official FLAC pages on SourceForge.


Vorbis Comments