Line based text exports and line breaks

Hello everyone,

I've looked through the documentation and the export sub-forum, but I can't find a solution to my problem. It's probably something simple that I have overlooked or maybe what I want to do is not possible.

When doing a line based export, say a CSV file, containing a lot of fields and field transformations it would be nice to be able to break up the export definition of a line into multiple lines. Let me explain.

A simple export could look like this.

$filename(csv,utf-8)artist,album
$loop(%_path%)%artist%,%album%
$loopend()

Now, imagine that I want to have some 30+ fields, some plain ones and some calculated/transformed ones. At this point the mte file becomes a maintenance nightmare. Consider a simple example of just a few fields.

$filename(csv,utf-8)artist,album,year,track,title,length,comment,size,bitrate,vbr
$loop(%_path%)"$replace(%artist%,","")","$replace(%album%,","")",%year%,%track%,"$replace(%title%,","")",%_length_seconds%,"$replace(%comment%,","")",%_file_size_bytes%,%_bitrate%,%_vbr%
$loopend()

With all those fields it's hard to tell which commas are part of function calls and which are meant for the final output, and it takes some careful editing to get all the double quotes right.

What I'm looking for is the possibility to split a multi-parameter method across multiple lines and to have a new method, e.g. $concat(x,y), that would concatenate the two strings x and y. With this I would be able to do something like the following.

$filename(csv,utf-8)artist,album,year,track,title,length,comment,size,bitrate,vbr
$loop(%_path%)$concat("$replace(%artist%,","")", $concat(',',
$concat("$replace(%album%,","")", $concat(',',
$concat(%year%, $concat(',',
$concat(%track%, $concat(',',
$concat("$replace(%title%,","")", $concat(',',
$concat(%_length_seconds%, $concat(',',
$concat("$replace(%comment%,","")", $concat(',',
$concat(%_file_size_bytes%, $concat(',',
$concat(%_bitrate%, $concat(',',
%_vbr%))))))))))))))))))
$loopend()

Having typed the above, I realize that a better request would be to have a method that would eat a carriage return/line feed pair (I'm going to call it eatcrlf in my examples). This would turn the above to something like the following.

$filename(csv,utf-8)$eatcrlf()
artist,$eatcrlf()
album,$eatcrlf()
year,$eatcrlf()
track,$eatcrlf()
title,$eatcrlf()
length,$eatcrlf()
comment,$eatcrlf()
size,$eatcrlf()
bitrate,$eatcrlf()
vbr
$loop(%_path%)$eatcrlf()
"$replace(%artist%,","")",$eatcrlf()
"$replace(%album%,","")",$eatcrlf()
%year%,$eatcrlf()
%track%,$eatcrlf()
"$replace(%title%,","")",$eatcrlf()
%_length_seconds%,$eatcrlf()
"$replace(%comment%,","")",$eatcrlf()
%_file_size_bytes%,$eatcrlf()
%_bitrate%,$eatcrlf()
%_vbr%
$loopend()

Having typed the above I realize a better yet request would be for a crlf-less mode and a $crlf() function. This would be the reverse to the above; carriage return/line feed pairs would be eaten by default and $crlf() would insert one such pair into the output. Consider the following ("eatcrlf" is just a made up example, of course).

$filename(csv,utf-8,eatcrlf)artist,album,year,track,title,length,comment,size,bitrate,vbr$crlf()
$loop(%_path%)
"$replace(%artist%,","")",
"$replace(%album%,","")",
%year%,
%track%,
"$replace(%title%,","")",
%_length_seconds%,
"$replace(%comment%,","")",
%_file_size_bytes%,
%_bitrate%,
%_vbr%$crlf()
$loopend()

Have I simply missed something in the documentation that I could use to do what I want, or is this a feasible feature request? Thanks in advance for any help.

EDIT: I found that the following works for me, I was wrong about the functions not being able to be defined across multiple lines in the mte file. I can work with this for now. I'm sorry you had to read through all of the above.

$filename(csv,utf-8)artist,album,year,track,title,length,comment,size,bitrate,vbr
$loop(%_path%)"$replace(%artist%,","")",$puts(a
,)"$replace(%album%,","")",$puts(a
,)%year%,$puts(a
,)%track%,$puts(a
,)"$replace(%title%,","")",$puts(a
,)%_length_seconds%,$puts(a
,)"$replace(%comment%,","")",$puts(a
,)%_file_size_bytes%,$puts(a
,)%_bitrate%,$puts(a
,)%_vbr%
$loopend()

That's a nice trick, still working in Mp3tag v2.58!

01: $filename($getEnv('USERPROFILE')'\Desktop\Mp3tag.Test.txt',UTF-8)$puts(

02: )'Artist,Album,Year,Track,Title,Length,Comment,Size,Bitrate,VBR'
03: $loop(%_path%)$puts(
04: )'"'$replace(%ARTIST%,'"','""')'"'$puts(
05: )',"'$replace(%ALBUM%,'"','""')'"'$puts(
06: )','%YEAR%$puts(
07: )','$ifgreater($strstr(%TRACK%,'/'),0,'"'%TRACK%'"',%TRACK%)$puts(
08: )',"'$replace(%TITLE%,'"','""')'"'$puts(
09: )','%_length_seconds%$puts(
10: )',"'$replace(%COMMENT%,'"','""')'"'$puts(
11: )','%_file_size_bytes%$puts(
12: )','%_bitrate%$puts(
13: )',"'%_vbr%'"'
14: $loopend()

DD.20140322.1243.CET