--- /dev/null
+#!/usr/bin/env zsh
+
+cat <<EOF
+%rec: Album
+%mandatory: Artist Album
+%allowed: Year Collection Lossless
+%type: Year int
+%type: Lossless bool
+
+EOF
+
+setopt EXTENDED_GLOB
+COLS=()
+for col (cols/*) COLS=($COLS $col:t)
+for name (*~cols) {
+ ts=(${(s/-/)name})
+ year=""
+ for (( i=2 ; i <= $#ts ; i++ )) {
+ [[ ${ts[$i]} =~ "^[0-9][0-9][0-9][0-9]$" ]] && {
+ year=${ts[$i]}
+ break
+ }
+ }
+ [[ -n $year ]] && {
+ artist=(${ts[1,$i-1]})
+ album=(${ts[$i+1,-1]})
+ } || {
+ artist=${ts[1]}
+ album=(${ts[2,-1]})
+ }
+ lossless=""
+ [[ -d $name ]] && {
+ wvs=($name/**/*.wv(N))
+ [[ ${#wvs} -gt 0 ]] && lossless=1
+ } || {
+ [[ $name:e = wv ]] && lossless=1
+ }
+ cols=()
+ for col ($COLS) [[ -e cols/$col/$name ]] && cols=($cols $col)
+
+ print "Artist: ${(j/-/)artist:gs/_/ /}"
+ [[ -n $year ]] && print "Year: $year"
+ print "Album: ${(j/-/)album:gs/_/ /}"
+ [[ -n $lossless ]] && print "Lossless: yes"
+ for col ($cols) print "Collection: $col"
+ [[ ${#cols} -eq 0 ]] && print "Collection: unsorted"
+ print
+}