Exporting to excel


I want to know how to add some blank lines to a cvs file (for excel) before doing totals. So that when imported into excel these totals will always be in the same cells not matter how manf music files Im get


:wink: A simple solution would be to always use the last possible row of an excel file, but that depends on the version of Excel.

Another thinkable solution would be ...
... detect the row of the last data line resp. count the rows of the data lines while reporting out,
... behind the loop add some blank lines up to the last fixed totals line.

For counting and retrieving you can use the functions $put, $puts, $get, $add.
... for example: $put(MyCounter,$add(MyCounter,1))

For creating forced linefeeds you can use the functions $char, $repeat
... for example: $repeat($char(13)$char(10),100)

To place the last line at the right position you have to do some calculation ...
... for example: $repeat($char(13)$char(10),$sub(100,$get(MyCounter)))

I've never tested this in reality, that is now your part.
Please show us your sample Mp3tag Export Language script.



Have attached script

What I was attempting to do was transfer the value of %counter% over to mycounter and always have the totals at line 12000 in my excel fil so that no matter how many I export as long as it is beloww 12000 the totals will always be at line 12000

When i run this script it puts the totals at line 1140Graeme.mte (569 Bytes)

Graeme.mte (569 Bytes)


Yes, using the system variable %_counter% there is no need to set up a user defined counter variable.
Right after a closed loop the system variable %_max_counter% provides the maximum count of the last loop.

I would code the report like this ...
(maybe it would be more safe to replace the semicolon delimiters by the tab character $char(9))

1: $filename($getEnv('USERPROFILE')'\Desktop\20120616.Test.Graeme.csv',UTF-16)'"ID";"Title";"Artist";"Album Artist";"Com";"Album";"Track";"Year";"Length";"Size";"Composer";"Path";"Filename"'

2: $loop(%_filename_ext%)'"'%_counter%'";"'%TITLE%'";"'%ARTIST%'";"'%ALBUMARTIST%'";"'%COMMENT%'";"'%ALBUM%'";"'%TRACK%'";"'%YEAR%'";"'%_length_seconds%'";"'%_file_size_bytes%'";"'%COMPOSER%'";"'%_folderpath%'";"'%_filename_ext%'"'
3: $loopend()$repeat($char(13)$char(10),$sub(17,%_max_counter%))
4: '"Check";"Total Files";"Size in Bytes";"Total Size";"Total Time";"Total Time in Seconds";"Date"'
5: '"'%_max_counter%'";"'%_total_files%'";"'%_total_size_raw%'";"'%_total_size%'";"'%_total_time%'";"'%_total_time_raw%'";"'%_datetime%'"'

You have to take into account the known quirk of the Mp3tag Export Scripting Language.
Each line of code in the report script itself, creates a linefeed in the report output file.
There is no way known today, how to suppress these unwanted linefeed output.

Regarding the example script from above, there are 3 lines to be subtracted implicitely (20-3=17), to get the totals section exactly into line 20 (valid for %_max_counter% <= 17).