Dmitry Leskov
 

Updated AddFLACs to Extract Track Metadata From Pathnames

I have updated AddFLACs, my iTunes for Windows automation script that I wrote back in 2011. It helps you import FLAC files into iTunes in Apple Lossless format.

About a week ago, a reader complained in the comments to the original post:

does it still skip over FLAC with no meteadata. (None of my FLAC have metadata, i always go by filename).

Fact is, I already had half-baked code for extracting metadata from pathnames using regular expressions, so today I integrated that code and published AddFLACs 1.0.

Now, for instance, if your untagged FLACs collection is hierarchically organized by artist and then by album, you can import it into iTunes as follows:

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

If file names begin with track numbers followed by a dash, you can extract track numbers too:

AddFLACs -r ".*\\(.*)\\(.*)\\(\d+)-(.*)\.flac$" ^
  -artist "$1" -album "$2" -tracknumber "$3" -name "$4"

Even if you are not a master of regular expressions, with some tooling you can go way further:

AddFLACs ^
  -r ".*\\(.*)\\(.*)\\(.*?)( \((\d{4})\))?\\(\d+)-(.*)\.flac$" ^
  -genre $1 -artist "$2" -album "$3" -year "$5" ^
  -tracknumber "$6" -name "$7"

I would recommend you to run it with --dry-run (-n) option first, to verify that all files match and metadata gets extracted as intended.

Refer to AddFLACs documentation for details.

Credits

I have used Regular Expressions 101, a terrific online regular expression tester and debugger, to debug the last example.

Tags: , ,

« | »

Talkback

* Copy This Password *

* Type Or Paste Password Here *