Howto fill 2 tags from one filename element in one single step?


via the Filename - Tag converter one can simply fill tags from a file and folder structure. This works straight forward in the case where one fills one single tag from one filename part, e.g.

10.000 Maniacs(1993) MTV Unplugged\01 - These Are Days.mp3
%artist%(%year%) %album%%track% - %title%

But how can I fill 2 tags from one single filename part?

I need to fill the year and the album tag from the name of the album in the filename, so that the album is not MTV Unplugged, but (1993) MTV Unplugged and I want to do that in one single conversion step.

How can I do this?

You can't.
You have to import the data first to one tag field and then copy it from there.

That's what I did so far, it is unfortunate that my requirement does not work. To whom can I send this requirement and how?

I doubt that it is physically possible to have 2 fieldnames in exactly the same space in pattern. They will always appear in sequence and consequently define a new pattern.
But perhaps you have a trick up your sleeve and you can enlighten me where I am too narrowminded.

The forum posts are regularly read by the developer, so your idea will not be lost.

This is only a matter of syntax.

In a first approximation one could think about simply specifying an arbitrary list of instructions concatenated with an & sign that then would be executed one after the other:

%artist%/(%year%) %dummy%/%track% - %title% & %dummy%/%album%/%dummy%

Next, one could define a new syntax element, e.g. a binary -> operator, like, e.g.

%artist%/() -> ((%year%) %dummy%, %album%)/%track% - %title%

I would also like to add a cover from the folder.jpg file inside of my folder in this step, which I also currently do via an extra action, but this is perhaps yet another story.

See, I was too narrowminded.

What you could do: use just one action of the type "Guess value" in which you prepare the source string in such a way that the data that is to be copied to several fields appears in the appropriate number of repetitions. THis could probably be done with a $regexp() function in which you use the $x parameters for the copies.
e.g. $regexp("10.000 Maniacs(1993) MTV Unplugged\01 - These Are Days",(.*)\((\d+)\) (.*)\\(.*),$1==$2==$2 $3==$4)
which leads to a string like
10.000 Maniacs==1993==1993 MTV Unplugged==01 - These Are Days
which you could then import to

thanks for pointing me to the regex functionality. I'm wondering whether one can use this idea directly in the Filename-to-Tag conversion, i.e. without defining an extra action.

I'm currently struggeling with the definition of the action you mentioned. Note also, that between the group name and the album name there is a backslash, too, which is not included in my initial post, because of the fact that tis editor here does print \( as (.

Damn... what the hell does this editor here, there are also other special characters that are not rendered as they are typed in...

10.000 Maniacs\(1993) MTV Unplugged\01 - These Are Days

I checked the following regex with an online regex tester and it seems to be okay:

(.*)\\\((\d+)\) (.*)\\(\d+) - (.*)

I currently don't know, how to give the system the string, with %1 or so, like this:

Unfortunately, this leads to a syntax error.

Could you be so kind to post how I need to fill in the fields in the action definition dialog above, surely, there is an error in.

%1 as parameter in the place of the $regexp() function where it expects a string or string reference leads to an error as %1 is just %1. If you want to treat the contents of the _FILENAME, use %_filename%.

The regexp part

looks ok to me, but you can test it inside MP3tag with Convert>Tag-Tag
You would need to modify

$1==$2==$2 $3==$4==$5)


Please note that the "==" is not mandatory, it just helps to create a unique separator between the parts of the input string %_FILENAME%.

I am still puzzled why you want to avoid actions when they could be addressed by name whereas Converter patterns can't.
Also I do not understand why you want to get it done in just one action, when the call of an action group with several actions in it (including the cover import) is just as quick and does so much more.

1 Like


I tried many many things out today and as a result, it seems to me that the regex parser in mp3tag does not work as, e.g. the regex tester in, which indicates to me that either the mp3tag regex parser does not work or I am doing something fundamentally wrong.

Note also, that _filename is not correct. This information field contains only the filename itself, i.e. 01 - These Are Days.
We need to pass also the _directory and the _parent_directory to the parser.

Btw. I'm wondering how one can go another step above in the folder hierarchy. There is no _parent_parent_directory information field :slight_smile:.

Good, let's play a bit with the Convert Tag->Tag functionality, because it goes faster.

I tried out the following regex and string

10.000 Maniacs\(1993) MTV Unplugged\01 - These Are Days
(.*)\\(\d+) gives me back the 2 matches

10.000 Maniacs\(1993) MTV Unplugged

which seems okay.

But, mp3tag's Tag->Tag Converter indicates me with

$regexp(%_parent_directory%\%_directory%\%_filename%, (.*)\(\d+), $1==$2)

this here

10.000 Maniacs\(1993) MTV Unplugged==01 - These Are Days

which is not correct because the second match is 01 - These Are Days instead of only 01.

What now?

There is hardly any use to lament over the differences between the results of some other test program and that what MP3tag makes of your regular expressions. You have to get them to work inside MP3tag.
Also, could you please enclose any code in accent grave (top left to bottom right) so that all the special characters stay in place?
I tried this and it looks ok to me:
$regexp("10.000 Maniacs\(1993) MTV Unplugged\01 - These Are Days",(.*)\\\((\d+)\) (.*)\\(\d+) - (.*),$1==$2==$2 $3==$4==$5)
->10.000 Maniacs==1993==1993 MTV Unplugged==01==These Are Days


I have it... as I said, I did something fundamentally wrong. In those cases where nothing works there is always a simple solution:

I typed spaces after each comma in the $regexp function, which one should never never do. I noticed this already several time ago, but I'm making always the same mistake.

$regexp(%_parent_directory%\%_directory%\%_filename%, (.*)\\\((\d+)\) (.*)\\(\d+) - (.*), $1==$2==($2) $3==$4==$5)

is different from

$regexp(%_parent_directory%\%_directory%\%_filename%,(.*)\\\((\d+)\) (.*)\\(\d+) - (.*),$1==$2==($2) $3==$4==$5)

And, yes, I'm aware of the fact that some regex test page shouldn't be compared with the tool, one must get run the thing inside of the tool itself.

Thanks for pointing me to the formatting functions of this editor, me stupid.

I have to thank you also for mentioning the action groups and that one can simply add actions to them. I, so far, had only one single action in it and wasn't at all aware of the group functionality. I must admit that until now, I mainly worked with the convert (ALT + x) menu and didn't dig so deeply into the powerful actions.

But the main thing, I learned from this thread was the usage of the regexp function and ist signature.

Many thanks for all this. I will try now to define all my manual steps into one single action and will hopefully succeed.