Custom First Letter Field

Hello Guys in MP3tag forums!

First I'd like to thank the developer of this program and all those who have contributed in these forums, you have probably saved months if not years of my life!

I have a question that you may be able to help with

I am currently in the process off overhauling/cleaning how I catalogue and tag my MP3 files
One of the things I am doing is adding a custom field to the tags of all my MP3s called FIRSTLETTER
The purpose of doing this is that I currently sort my music in the following way

Music\%firstletter%\%artist% - %album%$num(%track%,2) - %title% (currently being changed to Music\%firstletter%\%artist%\%album%$num(%track%,2) - %title%)
Music! Compilations\%album%$num(%track%,2) - %artist% - %title% (for compilations)

The firstletter field allows me to easily file tracks away both in the main library and when I want to move or copy files to external devices and keep the folder structure nearly identical.
Up until now I have been populating this field manually but it occurred to me during this overhaul that I could probably do this automatically which would save a great deal of time with compilations

I have attempted what was suggested in an earlier post on this forum and inserted this into a format value action and it works but I was wondering if I could take it a step further with your help.

Is there any way to add exclusions to the expression such as excluding the word 'The' for example.

Any help is greatly appreciated.

\m/ Guttersnipe \m/

Create an action group containing several actions:

  1. First, create a temporary field and copy artist name.

Action type: Format value
Field: TEMP
Format string: %artist%

  1. Remove any leading article.

Action type: Replace with regular expression
Field: TEMP
Regular expression: ^(the|el|los|la|las|le|les)\s(.+)$
Replace matches with: $2
[ ] case-sensitive comparison

  1. Grab the first letter of the temporary field.

Action type: Format value
Format string: $left(%temp%,1)

  1. Then delete the temporary field.

Action type: Remove fields
Fields to remove: TEMP

It's also possible to do it in a single action.

Action type: Format value
Format string: $left($regexp(%artist%,^(the|el|los|la|las|le|les)\s'('.+')'$,$2,1),1)

Also be aware that once you've renamed the file, there's no good reason to keep the field FIRSTLETTER, since it's easily recreated from the artist name. You can place this action after your action (or action group) that renames the file:

Action type: Remove fields
Fields to remove: FIRSTLETTER

Thanks you very much for this.
I think I'll keep the field as occasionally i copy and sort files according to the first letter and it ouwld be nice to have the field there ready.

Many thanks for your efforts though! :smiley: