#!/bin/bash
file=$1
mkdir songs

iconv -f CP1250 -t UTF-8 "$file" | tr -d '\r' | sed 's/.R:/R:/g' | sed 's/<song.*title="\([^"]*\)".*author="\([^"]*\)".*/#name###\1###\2###/g' | sed 's/<[^>]*>//g'  | sed 's/^.[0-9][0-9]*.$//g' | awk '
BEGIN { song=""; FS="###";}
/#name###/ {  song=$2; songfile = "songs/" song; printf("##title:%s\n##author:%s\n====\n", $2, $3) > songfile; next }
// { if(song=="") next; else {  printf("%s\n", $0) >> songfile; next; } }
' 

