Automated sort order tags

Is anybody interested in how to write a script for automatically generating a sort order tag from an artist tag? I have written a script to do it, part of which I'll reproduce below. (It is too bad that you can't export scripts from Mp3Tag.)

  1. Merge duplicate fields "ARTIST": ";"
  2. Format value "TVSEASON": %artist%
  3. Format value "TVEPISODE": $If($grtr($strchr(%tvseason%,';'),0),$trim($left(%tvseason%,$strchr(%tvseason%,';')),';'),%tvseason%)
  4. Format value "TVEPISODE": $right(%tvepisode%,$sub($len(%tvepisode%),$strrchr(%tvepisode%,' '))), $trim($left(%tvepisode%,$strrchr(%tvepisode%,' ')))
  5. Format value "TVEPISODE": $If($eql($len(%tvseason%),0),,%tvepisode%)
  6. Format value "ARTISTSORTORDER": $If($grtr($len(%tvepisode%),0),%tvepisode%,%artistsortorder%)
  7. Format value "TVSEASON": $If($grtr($strchr(%tvseason%,';'),0),$right(%tvseason%,$sub($len(%tvseason%),$strchr(%tvseason%,';'))),)
  8. Format value "TVEPISODE": $If($grtr($strchr(%tvseason%,';'),0),$trim($left(%tvseason%,$strchr(%tvseason%,';')),';'),%tvseason%)
  9. Format value "TVEPISODE": $right(%tvepisode%,$sub($len(%tvepisode%),$strrchr(%tvepisode%,' '))), $trim($left(%tvepisode%,$strrchr(%tvepisode%,' ')))
  10. Format value "TVEPISODE": $If($eql($len(%tvseason%),0),,%tvepisode%)
    11.Format value "ARTISTSORTORDER": $If($grtr($len(%tvepisode%),0),%artistsortorder%;%tvepisode%,%artistsortorder%)
  11. Remove fields "TVEPISODE;TVSEASON"

This program assumes that if more than one artist appears in the Artist tag, they are separated by ';'. The first line is needed only if you have multiple Artist tags. TVSEASON and TVEPISODE are used to store values, on the assumption that we're dealing with music files that won't already have these tags in use. (Any empty fields would do. I don't know how else to store values.)

The program will will do up to two artists, which it separates with ';'. It converts First Last order to Last, First. If you want to be able to do more artists, iterate lines 7-11. My own version does five iterations, which should be enough. If there's a way to conditionally halt programs, I'm unaware of it. (That could easily be! Today is my first attempt to write any scripts for Mp3Tag.)

The program is no doubt inelegant, but I think it is correct. I hope it may help others who want to automate this job.

You can share your action, it is stored in a mta file which you can find in the profile folder:
You can zip it and attach it to your post.

Ok, it is attached. (505 Bytes)