summaryrefslogtreecommitdiffstats
path: root/kioslave/audiocd/upgrade-metadata.sh
blob: 000323b1d3cbf42d09942691e1d1fb7b4768e64b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /usr/bin/env bash

while read; do
    if [ "${REPLY#\[}" != "$REPLY" ] ; then # group name
	GROUP="${REPLY:1:${#REPLY}-2}"
	continue;
    fi
    # normal key=value pair:
    KEY="${REPLY%%=*}"
    VALUE="${REPLY#*=}"

    case "$GROUP/$KEY" in
	FileName/file_name_template)
			#
			# Swap
			#
			VALUE=`echo $VALUE | sed -e s/%a/%{albumtitle}/g`;
      VALUE=`echo $VALUE | sed -e s/%t/%{title}/g`;
      VALUE=`echo $VALUE | sed -e s/%n/%{number}/g`;
      VALUE=`echo $VALUE | sed -e s/%g/%{genre}/g`;
      VALUE=`echo $VALUE | sed -e s/%y/%{year}/g`;
      VALUE=`echo $VALUE | sed -e s/%A/%{albumartist}/g`;
	    echo "[FileName]";
			echo "file_name_template=$VALUE"
	    echo "# DELETE [FileName]file_name_template"
			;;
    esac
done