text functions in Actions

I'm just trying to get my head around MP3TAG, and probably asking a silly question, but after days of struggling to understand the examples so helpfully posted, I'm still baffled:

Here is an example of what I'm trying to do:

say I have music with the following filenames:

movement1Allegro.mp3
movement2Andante.mp3
movement3Adagio.mp3
movement4Presto.mp3

and the corresponding TITLE tags:

track 01
track 02
track 03
track 04

I want to change the TITLE tags to read

01 Allegro
02 Andante
03 Adagio
04 Presto

So I try:

Action type: Format value
Field: TITLE
Formatstring: $right(%title%,2) $right(%filename%,(len(%filename%)-9))

But although a straight tag value in the Formatstring will return the contents of that tag, functions don't appear to work in Actions. How should I proceed?

Apologies if I use incorrect names for things, but I hope you understand what I'm driving at.

A couple of questions first:

  1. Do you have any other fields besides TITLE in the files? Specifically, is TRACK present and correct?

  2. Are you sure you want/need the track number in the track's title? It's usually not necessary for an application to play the album in the correct order, if the track number field is correct.

  3. Do you also want to rename the files? In this case, you generally do want the track number in the filename, usually as the first component, so that the tracks appear in order when viewing the directory contents. I would probably use your proposed TITLE format for the filenames. E.g.

01 Allegro.mp3
02 Andante.mp3
03 Adagio.mp3
04 Presto.mp3


Yes, functions work within Actions and format strings.  There are two errors in your format string:

$right(%title%,2) $right(%filename%,(len(%filename%)-9))

1. There should be a $ sign before the 'len' function name, as with all functions.
2. %filename% should be %_filename%.  "Special" field names are preceded by an underscore, as shown on this help page:

<a href="https://docs.mp3tag.de/converters" target="_blank">https://docs.mp3tag.de/converters</a>

Let's assume that the track number is not present in the tags.

Action type: Format value
Field: TRACK
Format string: $mid(%_filename%,9,1)

Then get the TITLE with no track number:

Action type: Format value
Field: TITLE
Format string: $mid(%_filename%,10,99)

If you still want the track number in the title, use

Action type: Format value
Field: TITLE
Format string: $num(%track%,2) %title%

And to rename the files as I suggested above, use the same format string on _FILENAME:

Action type: Format value
Field: _FILENAME
Format string: $num(%track%,2) %title%

If you make the above an Action Group (multiple actions) be sure you don't execute it twice on your files or you'll screw things up pretty thoroughly.

Thank you so much for your help. Sorry about typos leaving out $ signs etc, although actually I think I got them right when experimenting.

Of course your solution worked perfectly, so I don't know how came to believe I couldn't use functions in Actions -- I must have done something silly, and then been too discouraged to continue because I'd already found that if I try to introduce a function in the Action: Replace, then it seems to replace with the function description I entered instead of the function result I want. Is that what is meant to happen? And yes, I have Track numbers OK.

But anyway, when I tried functions in Format value as in your suggestion it worked (so goodness knows what I did wrong previously), and thanks again for your patience in providing such a full explanation.

I wanted the movement numbers in the titles just to show which movement out of a number of movements was playing, but if I could have programmed in multiple substitutes of I, II, III, IV for 01, 02, 03, that would be even better. Is that sort of thing possible with this arcane Regular Expressions stuff?

For some reason I have a particular problem with German software, in that I sometimes get the feeling that help files are written by people who utterly understand how their system works, but have forgotten what it's like to be a keen but clueless first time user. In the case of MP3TAG, they provide a perfect single representative example of each feature, but only one example per feature -- after all, why clutter up the help pages with more? Well, a bit of extra clutter in the form of 3 or 4 varied examples of the same feature would help a moron like me begin to discern patterns of use that reveal the underlying principles that the experts understand so well that they don't think there's anything TO understand... But then, the best German software is just so much better than the competition that a steep learning curve is worth following. For me and my colleagues, Samplitude, for instance, has been just miles ahead of all other audio applications for at least 6 years.

Anyway, sorry to rabbit on, and thanks again.