Export/Scripting Function Help

I'm trying to figure out if or how I would do something if I made a format switch in the way I tag things. Some of the big players out today support "Multiple Artists" in the artist field, which is what this problem centers around. The player I use (MediaMonkey) has supported this for some time, but I've been hesitant to take full advantage of it.

The main reason is the fact that 90% of my music is from the Rap genre, and I'm sure if you're a fan or even if you've simply looked at a few tracklists for some recent releases, you will notice that they often feature a lot of artists outside of the main artist. That being said, we're not talking about one or two Tim McGraw & Faith Hill collaborations on one album where it's easy to tell who's song it is and such, we're talking many with many different artists, even on the same song.

That wouldn't really be a problem either, given the Album Artist field (or Band in MP3Tag terms), but there are even cases where a few songs on the albums are actually someone elses songs all together. Even though I could deduct who's song it is and everything, I would still like to maintain some form of notation of these collaborations.

Currently I run a formant such as "Artist 1 - Title (ft. Artist 2, Artist 3 and Artist 4)," however this does no good in grouping this song with Artist 4's other work as the information is in with the title. I'm thinking of moving to a format like "Artist 1/ft./Artist 2/Artist 3/Artist 4 - Title," as I then could take advantage of the multiple artists feature while still indicating that it's 2, 3 and 4 on 1's song. This would result in a dummy "ft." artist, but I could live with that.

The problem I'm trying to figure out before I even get to it isn't how to make this move, I'm about 95% sure I could figure out the coding to make this move painless. My problem is then how to use this information in exports that works for what I've been doing in the past.

There are some cases where I want to separate the featured artists from the title to present two separate pieces of information. One example of when I do this is when I use MP3Tag to do the grunt work when creating tables for albums on Wikipedia. (see Killer (Tech N9ne album)) As you can see, there is a separate column for both Title and Featured Artist(s), which were mainly produced by running an MP3Tag export on the album.

$if($eql($right(%Title%,1),')'),$regexp(%title%,(.*) \(ft\. .*\),$1),%title%)

$if($eql($right(%Title%,1),')'),$regexp($replace(%title%, and ,',' ),.* \(ft\. (.*)\),$1),)

There are the two snippets I've worked up to handle these two columns, Title and Featured Artist(s) respectively. Since I use "Title (ft. Artist)," I can easily find the tracks which have features artists by looking for the ")" at the end of the title (since I use "[" & "]" for Remix and other such information), then either using the RegExp to get just the title portion, or if that track doesn't feature anyone, just exporting the Title field. The code for the featured artist works exactly the same, except exporting only the artists from the title or nothing if there isn't anything (as in, no ")")

Again, still not the problem. Though, this is where the problem is introduced. If I make this format change, I would no longer need to split the artists from the titles, but I would still like to split the main artists from the featured artists in the new format. I can't even for the life of me begin to wrap my head around if it's even possible or how to search for "/ft./" in the Artist field, spliting it wouldn't be much problem as it would just need a RegExp. It's all about how, or even if, I would be able to find these tracks with featured artists to even make the split that has me halted in my plans to make such a switch.

Anyone great with MP3Tag's Scripting Functions and Export Framework to be able to tell me if it's even possible, or even give me the magical string that would accomplish this?

I've actually looked over the scripting functions, but I not familiar with some of them and thus haven't gotten anywhere. Couldn't use an explicit nth character search because some artists names are longer than others, so "/ft./" wouldn't always be in the exact same spot.

Shrugs I'm lost. I would appreciate any help offered in figuring this out. Heck, I'd say thank you to those who even take the time to read through this entire post, since it has turned out rather long. Probably could have cut to the chase a little sooner, sorry about that.

PS - Wow, I hope that even makes sense, otherwise I wasted some people's time. :astonished:

EDIT: Thought I would try to give a quick overview of what it is I'm looking to do. I'm looking to take the string "Artist 1/ft./Artist 2/Artist 3/Artist 4" from the Artist field, and in Export, be able to get two separate values of "Artist 1" and "Artist 2/Artist 3/Artist 4", but would like to be able to run it on a group of tracks which feature that format and also some which only have "Artist 1" in the Artist field. Thus I need a way to find the files with "/ft./" in the Artist field in an $if so I could then run a RegExp to get the separate values, or if that string isn't found, export the field as-is. Hopefully that helps clarify what it is I'm looking to do.

I've tried this, and it seems to work - the hard way ... it should exist a more simple way (especially if you could use the 'meta' tag field format and $meta scripting functions).

$loop(%path%)

$puts(ItemCount,$add(1,$sub($len(%artist%),$len($replace(%artist%,'/',)))))

$puts(a5,)
$puts(a4,)
$puts(a3,)
$puts(a2,)
$puts(a1,)
$puts(out,)

$puts(a5,$if($eql($get(ItemCount),5),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)/(.+?)/(.+?)$',$5,1),$get(a5)))
$puts(a4,$if($eql($get(ItemCount),5),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)/(.+?)/(.+?)$',$4,1),$get(a4)))
$puts(a3,$if($eql($get(ItemCount),5),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)/(.+?)/(.+?)$',$3,1),$get(a3)))
$puts(a2,$if($eql($get(ItemCount),5),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)/(.+?)/(.+?)$',$2,1),$get(a2)))
$puts(a1,$if($eql($get(ItemCount),5),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)/(.+?)/(.+?)$',$1,1),$get(a1)))

$puts(a5,$if($eql($get(ItemCount),4),,$get(a5)))
$puts(a4,$if($eql($get(ItemCount),4),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)/(.+?)$',$4,1),$get(a4)))
$puts(a3,$if($eql($get(ItemCount),4),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)/(.+?)$',$3,1),$get(a3)))
$puts(a2,$if($eql($get(ItemCount),4),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)/(.+?)$',$2,1),$get(a2)))
$puts(a1,$if($eql($get(ItemCount),4),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)/(.+?)$',$1,1),$get(a1)))

$puts(a5,$if($eql($get(ItemCount),3),,$get(a5)))
$puts(a4,$if($eql($get(ItemCount),3),,$get(a4)))
$puts(a3,$if($eql($get(ItemCount),3),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)$',$3,1),$get(a3)))
$puts(a2,$if($eql($get(ItemCount),3),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)$',$2,1),$get(a2)))
$puts(a1,$if($eql($get(ItemCount),3),$regexp(%artist%,'^(.+?)/(.+?)/(.+?)$',$1,1),$get(a1)))

$puts(a5,$if($eql($get(ItemCount),2),,$get(a5)))
$puts(a4,$if($eql($get(ItemCount),2),,$get(a4)))
$puts(a3,$if($eql($get(ItemCount),2),,$get(a3)))
$puts(a2,$if($eql($get(ItemCount),2),$regexp(%artist%,'^(.+?)/(.+?)$',$2,1),$get(a2)))
$puts(a1,$if($eql($get(ItemCount),2),$regexp(%artist%,'^(.+?)/(.+?)$',$1,1),$get(a1)))

$puts(a5,$if($eql($get(ItemCount),1),,$get(a5)))
$puts(a4,$if($eql($get(ItemCount),1),,$get(a4)))
$puts(a3,$if($eql($get(ItemCount),1),,$get(a3)))
$puts(a2,$if($eql($get(ItemCount),1),,$get(a2)))
$puts(a1,$if($eql($get(ItemCount),1),%artist%,$get(a1)))

$puts(out,$if($eql($get(ItemCount),5),$get(a1)' '$get(a2)' '$get(a3)'/'$get(a4)'/'$get(a5),$get(out)))
$puts(out,$if($eql($get(ItemCount),4),$get(a1)' '$get(a2)' '$get(a3)'/'$get(a4),$get(out)))
$puts(out,$if($eql($get(ItemCount),3),$get(a1)' '$get(a2)' '$get(a3),$get(out)))
$puts(out,$if($eql($get(ItemCount),2),$get(a1),$get(out)))
$puts(out,$if($eql($get(ItemCount),1),$get(a1),$get(out)))

'Input: #'%artist%'#'
'ItemCount: #'$get(ItemCount)'#'

'Artist 1: #'$get(a1)'#'
'Artist 2: #'$get(a2)'#'
'Artist 3: #'$get(a3)'#'
'Artist 4: #'$get(a4)'#'
'Artist 5: #'$get(a5)'#'

'Output: #'$get(out)'#'

$loopend()

The above export script creates this output:

Input: #Artist 1/ft./Artist 2#
ItemCount: #3#

Artist 1: #Artist 1#
Artist 2: #ft.#
Artist 3: #Artist 2#
Artist 4: ##
Artist 5: ##

Output: #Artist 1 ft. Artist 2#

Test_Mizery_Made.4.mte (2.69 KB)

DD.20081203.1648.CET

Test_Mizery_Made.4.mte (2.69 KB)

Doesn't really work for what I was looking to do, but that's actually an interesting little process. I think I'll tuck it away somewhere, might find a good way to use it.

Anyway, after sitting down and simply messing around with things until I either got it to work, or completely broke something, I think I found a solution that works for my needs.

$replace($if($eql($regexp(%artist%,.+/ft\./.+,~Yes~),~Yes~),$regexp(%artist%,(.+)/ft\./(.+),$2),),/,',' )

It took forever before the idea of using a regexp to search withing the field for criteria to match it, but after messing with several failed ideas, it finally came to me. I've yet to find a case that breaks this method, so I can go back to easily exporting tracklists for Wikipedia with ease. :slight_smile:

In fact, I used it yesterday to run through a create a tracklist and it works flawlessly. See Misery Loves Kompany

{| class="wikitable"
|-
!align="center" |#
!align="center" |Title
!align="center" |Songwriter(s)
!align="center" |Producer(s)
!align="center" |Featured guest(s)
!align="center" |Length
$loop(%_path%)|-
|$num(%Track%,1)
|%Title%
|%Wiki-Writer%
|$replace(%Conductor%,/,',' )
|$replace($if($eql($regexp(%artist%,.+/ft\./.+,~Yes~),~Yes~),$regexp(%artist%,(.+)/ft\./(.+),$2),),/,',' )
|%_length%
$loopend()|}

$loop(%Band% - %Album%,1)~%_total_time2%~$loopend()

Simply ran that export, manually edited in the Wiki-Links, and it was "Mission: Complete" :slight_smile: I love how MP3Tag can make certain things a breeze with Exports. :slight_smile:

Thanks DetlevD though for taking the time to look at this and offer a possible solution. Tis appreciated.