BEGIN { OFS="\t" } { gsub("&", "\\\\&") id = $1 type = $2 year = substr($3, 1, 4) + 0 title = $4 if (type == "Single") line = format_single else if (type == "Album") line = format_album else if (type == "EP") line = format_ep else line = format_album if (year) line = line " " format_year sub("<>", title, line) sub("<<year>>", year, line) print id, line }