Help needed with exporting tags for log/speadsheet

Hi there, i'm new to MP3tag and only know so much about coding, i've managed to corner myself into a dark room of %_directory%'s and %loop('s after trying all i can with some exporting.

What i'm trying to achieve is the ability to drop a 'Music' folder of many /Artist/Album/Track/splits.ogg's (converted from mp3's with all the needed tags) into MP3Tag and have the csv come out in a way i just haven't been able to work out. Coding i've done seems to work perfectly when i only drop one album at time in for extraction, but with another artist i've only come so close.

There could be a better way to do all this, my plans beyond this might be unnecessary if i can just upload a nice clean html to my googledrive to share, i guess i'm just not quite aware of the possibilities, so i'd appreciate all the help i could get, so much, so will all the people i plan to share this project with. Beyond this CSV i want my google sheet to come out something like the picture i've provided. i haven't coded in the STATUS section yet, shouldn't have issue there though.

This is the code (all the ; are for sheets, they work fine)


This is how the csv comes out

1/09/2019 12:42:56 AM
 ;Marilyn Manson
	;;[2015];The Pale Emperor;;;;;212.28 MB
		;;;;1.;Killing Strangers;;05:36;18.43 MB
			;;;;;;Drums;05:36;6.33 MB
			;;;;;;Rhythm;05:36;1.40 MB
			;;;;;;Song;05:36;6.01 MB
			;;;;;;Vocals;05:36;4.68 MB

		;;;;2.;Deep Six;;05:02;16.06 MB
			;;;;;;Drums;05:02;5.14 MB
			;;;;;;Rhythm;05:02;1.00 MB
			;;;;;;Song;05:02;5.52 MB
			;;;;;;Vocals;05:02;4.39 MB

		;;;;3.;Third Day Of A Seven Day Binge;;04:30;14.83 MB
			;;;;;;Drums;04:30;5.31 MB
			;;;;;;Rhythm;04:30;1.75 MB
			;;;;;;Song;04:30;4.31 MB
			;;;;;;Vocals;04:30;3.46 MB

And this is how it comes out with another Album/Artist added

1/09/2019 12:26:40 AM
	;;[1995];Frogstomp;;;;;355.37 MB
		;;;;01.;Israel's Son;;05:18;15.91 MB
			;;;;;;Drums;05:18;4.76 MB
			;;;;;;Rhythm;05:18;1.20 MB
			;;;;;;Song;05:18;7.00 MB
			;;;;;;Vocals;05:18;2.95 MB

		;;;;1.;Killing Strangers;;05:36;18.43 MB
			;;;;;;Drums;05:36;6.33 MB
			;;;;;;Rhythm;05:36;1.40 MB
			;;;;;;Song;05:36;6.01 MB
			;;;;;;Vocals;05:36;4.68 MB

		;;;;2.;Deep Six;;05:02;16.06 MB
			;;;;;;Drums;05:02;5.14 MB
			;;;;;;Rhythm;05:02;1.00 MB
			;;;;;;Song;05:02;5.52 MB
			;;;;;;Vocals;05:02;4.39 MB

		;;;;02.;Tomorrow;;04:26;14.85 MB
			;;;;;;Drums;04:26;5.08 MB
			;;;;;;Rhythm;04:26;1.08 MB
			;;;;;;Song;04:26;5.55 MB
			;;;;;;Vocals;04:26;3.14 MB

Thanks in advance for even reading all this :stuck_out_tongue:

If you want to export to a spreadsheet, I think it is better to use $char(9) to separate the individual fields.
I am not sure why you loop by %_directory% instead of a combined key like

Hey thanks for your suggestion, and the reason is because i don't really understand how the loop works and directory was giving me the closest result to what i was after, i'll give your code a try

See the help:
$loop(%fieldname%) starts a new loop. The loop data is sorted by the fieldname.
$loopend() ends a loop.
If you want to limit the loop output to a certain number of entries, simply use $loop(%fieldname%,num) . This is useful to eliminate duplicate records (num=1).

So you can either use several, nested loops to first sort by ARTIST (or ALBUMARTIST), then by ALBUM and finally by TRACK - which IMHO gives the best representation of an album.
The $loop() is sort of the 1:n relation between the items:
you have 1 artist with n albums and on 1 album there are n tracks.

Thanks for the help again, but i have no idea how to put that into use, i've sat for the last hour and tried to play around but i always end up with close to the same result, where it goes through each album til its found all track 1s, then 2's, so on. I just don't understand when to start a loop, end a loop, how many i should even be using, or i guess how a loop even works, it seems i can get every part of it working up until a point..

Artist Eminem
Track: Curtains Up (Skit)
Drums;00:30;126.87 KB
Rhythm;00:30;140.09 KB
Song;00:30;518.56 KB
Vocals;00:30;305.91 KB

Artist Rammstein
Drums;05:23;5.25 MB
Rhythm;05:23;1.07 MB
Song;05:23;7.12 MB
Vocals;05:23;3.50 MB

Artist KoRn
Track: Here To Stay
Drums;04:31;4.34 MB
Rhythm;04:31;2.00 MB
Song;04:31;5.80 MB
Vocals;04:31;2.88 MB

This is the other 'as close as i can get'. Does the songs in order but still won't list the artist at the start of each album listing like:


    • Album
      • Tracks
        • Subtracks
    • Album by same artist
      • tracks
        • subs


    • Album
      so on

Result 2:
2/09/2019 1:25:40 AM
;Muse ;Eminem ;Eminem ;Rammstein ;KoRn ;Silverchair (so on and so on)
;;[2010];The Wild Trapeze;;;;;16.28 MB
;;;;1.;The Wild Trapeze;;04:12;16.28 MB
;;;;;;Drums;04:12;5.21 MB
;;;;;;Rhythm;04:12;1.50 MB
;;;;;;Song;04:12;6.12 MB
;;;;;;Vocals;04:12;3.44 MB

	;;[2010];The Wild Trapeze;;;;;14.96 MB
		;;;;2.;Here Comes Everyone;;03:47;14.96 MB
			;;;;;;Drums;03:47;5.11 MB
			;;;;;;Rhythm;03:47;1.52 MB
			;;;;;;Song;03:47;5.43 MB
			;;;;;;Vocals;03:47;2.91 MB

	;;[2010];The Wild Trapeze;;;;;12.14 MB
		;;;;3.;Dance While The Devil Sleeps;;03:10;12.14 MB
			;;;;;;Drums;03:10;3.56 MB
			;;;;;;Rhythm;03:10;1.46 MB
			;;;;;;Song;03:10;4.66 MB
			;;;;;;Vocals;03:10;2.45 MB

the script could look like this:
$loop(%artist%)$loop(%album%)%artist% - %album%
$loop(%track%)$num(%track%,2) - %title% : %_length%

1 Like

Thanks, i think i'm finally starting to get it, your code is probably better for converting to sheets with coloured boxes indicating what stems each song has, and my layout is maybe better for comparing sizes and other data, i'll see what i can work out and most likely be back in a bit to mark you as the solution. again, thank you

So close you good thing :smiley: , but my fault for not knowing what i wanted sooner, i just realised it's not checking folder order in Artist folders, just an overall alphabetical scheme, i'd like [2002] The Eminem Show to be submitted to the list before [2004] Encore when two albums are being logged at the same time, if possible.

I'm not sure about grouping on the list; albums i will process later; with an artist's albums i previously logged, or how hard that would be, but if that is an easy task i'd love some help there too. The code is still mentioning the Artist name after the first mention, (in this case Eminem - Encore and then Eminem - The Eminem Show) but this is probably more ideal (for searching the log purposes) if or when i'm not submitting all of an artist's work at one time, if we can't insert new lines in the middle of old log i mean.

I think i solved the Multiple appearance of Artist name just by moving it back a tad, still on the 1st line but before the $loop(%album%). If that's correct i can just move that back based on whatever decision i end on / whatever ends up being possible

The $loop() statement is the command to sort the data.
If you do not want to sort by ALBUM alone, but by YEAR first, then insert $loop(%year%) before the $loop(%album%).
You will have noticed that the field in $loop() stays invisible and is not output - you have to use %artist% (or whatever) outside $loop() as field variable.

The script layout reflects in some way the layout of the output.
So an extra line in the script also becomes an extra line in the output.

In respect to the repeated semicoli, I would like to draw your attention to
$repeat(x,n) returns the string x n times.
This may ease the programming of the indents.

1 Like

So helpful, you're a godsend, i could already tell i couldn't do this without you, but then when i entered another Loop/album before the one already there, well that removed any final doubt haha. a bit too tired at 4am xD

With the exception of adding more albums to an artist already logged, i can report that you've solved all my problems and helped me to understand the logic of the loop better too.
I'll post and finish up the thread with marked solutions when i've finished perfecting my code :slight_smile:

Thanks for all that, you've helped me achieve so much, i've spent the last 2 days trying out different things seeing how far i could get so i didn't have to keep asking stuff, and i think it's safe to say i have most of the parts i need figured out, the only thing i haven't worked out is putting an if gate in for the Drum Rhythm Vocals and Songs fields (seen in image), when the sheet field finds something other than the desired file name it returns red like it has, but this only happened because there was no Vocal.ogg in the folder with the other 3 and so all the info moved a field over, i'd rather this happen because an if gate was returning a No Stem result.
Here's my code to add to the collection, if anyone would ever want it, probably not, i know i've done some strange stuff with the puts and gets, i got bored haha :stuck_out_tongue:

Submitted: %_datetime%.

$loop(%album%,1)$loopend()%_max_counter% Albums, $loop(%title%,1)$loopend()%_max_counter% Titles
$loop(%artist%,1)$loopend()%_max_counter% Bands or Arists, with $loop(%albumartist%,1)$loopend()%_max_counter% featurettes
Roughly [$grtr($div($div($div($div($div(%_total_time_raw%,4),60),60),60),24),0) Days, ]$div($div($div(%_total_time_raw%,4),60),60) Hours & $mod($div(%_total_time_raw%,4),60) Minutes of Music
Expected Stem Count: $loop(%_directory%,1)$loopend()$mul(%_max_counter%,4).
Actual Stem Count: $loop(%_path%,1)$loopend()%_max_counter%.
$loop(%_directory%,1)$loopend()$ifgreater($mul(%_max_counter%,4)$loop(%_path%,1)$loopend(),%_max_counter%,ERROR!,Yay!) $loop(%_directory%,1)$loopend()$sub($mul(%_max_counter%,4)$loop(%_path%,1)$loopend(),%_max_counter%) Stem(s) Missing

$loop($if(%albumartist%,%albumartist%,%artist%))%artist%$repeat(;,6)$ifgreater(%_total_size_raw%,$loop(%album%,1)$loopend()%_total_size_raw,%_total_size%,1 Album)$loop(%year%)$loop(%album%)
$loop(%track%,1) $repeat(;,3)$num(%track%,2);%title%;%_length%;%_total_size%;$loop(%title%,4)$loop(%title%,4)%_filename%;$loopend()$loop(%title%,4)%_length%;$loopend()$loop(%title%,4)%_file_size%;$loopend()$loop(%title%,4)%_samplerate% HZ;$loopend()
$loopend()$puts(TRUESEC,$div(%_total_time_raw%,4))$puts(SECONDS,$mod($get(TRUESEC),60))$puts(TMS,$sub($get(TRUESEC),$get(SECONDS)))$puts(MINUTES,$mod(%div($sub($get(TRUESEC),$get(SECONDS)),60),60))$puts(HOURS,$mod($div($div($sub($get(TMS),$mul($get(MINUTES),60)),60),60),24))$puts(DAYS,$div($div($div($sub($get(TMS),$mul($get(MINUTES),60),$mul($get(HOURS),60),60),60),60),24))$repeat(;,5)Total [$get(DAYS)d ]$get(HOURS):$get(SECONDS):$num($get(MINUTES),2);%_total_size%

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.