Removing a specific value - but only for a specific fileformat

Sometimes my TTA files have tta or TTA written in their _FIENAMEs, i.e. before the extension

Something as simple as just replacing " tta" with disregard for case-sensitive comparison in TITLE field does the trick. And I use that single pause [i.e. " tta" instead of "tta"] as a fail-safe - but I would like to add another layer to it:

I need to make this action work only for files in TTA format, which will reduce the number of wrong usages thus error [thus data loss]

So how do I do that? I am guessing I would need to use Replace with regular expression instead of ordinary Replace

Just use a filter F3 first to reduce your list to your TTA files.
Then execute your action to this filtered list of files.

But I need this as an single action; as in using a single groups action and not combining it with other Mp3tag features

@ohrenkino explains here why it is not possible to use a filter in a action.

If you replace a text constant with another text constant (in this case constantly nothing) then you only need an action of the type "Replace".

I have just scanned my collection and found "Whole lotta love", "Gotta be strarting something", "Loretta", "Violetta" as part of a Verdi opera, "Outtake" as part of a title, "Attack of the clones" - so there are a lot of titles (and probably filenames) with tta in them
I also wonder how the presence of these 3 letters would lead to

If you really want to go that way, you could use something like this in your "Format value" action:
$if($eql('TTA',$upper(%_extension%)),$repl(%TITLE%,' tta ',' '),)

Please don't use this abbreviated syntax!

As found in this bug report, the abbrevation of $repl instead of using $replace can result in unwanted changes. Always use $replace as stated in the help.

This would replace the text space tta space with a single space whenever the extension of the current file is TTA. You have to adjust it to your needs and use cases.

As @ohrenkino told you: This will also remove the bold marked text from titles:
Let tta and Cathode
or
Too young tta way

Either I am unable to imagine negative consequence - or both of you did not understand me


The data loss will occur precisely in such cases like @ohrenkino examples - if I will not use the first fail safe [i.e. " tta" with a pause]

All in all, based on this

I went with

$if($eql('TTA',$upper(%_EXTENSION%)),$repl(%TITLE%,' tta',' '),)
$if($eql('TTA',$upper(%_EXTENSION%)),$repl(%TITLE%,' TTA',' '),)
$if($eql('TTA',$lower(%_EXTENSION%)),$repl(%TITLE%,' tta',' '),)
$if($eql('TTA',$lower(%_EXTENSION%)),$repl(%TITLE%,' TTA',' '),)

as I failed at adding The fourth optional parameter enables ignore case (1) [Scripting Functions – Mp3tag Documentation]; i.e. those did not work

$if($eql('TTA',$upper(%_EXTENSION%)),$repl(%TITLE%,' tta',' ',1),)
$if($eql('TTA',$lower(%_EXTENSION%)),$repl(%TITLE%,' tta',' ',1),)

and neither did those

$if($eql('TTA',$upper(%_EXTENSION%)),$repl(%TITLE%,' tta',' '),1)
$if($eql('TTA',$lower(%_EXTENSION%)),$repl(%TITLE%,' tta',' '),1)



And on the side note- I stumbled upon a bug: Similar actions get mixed up when using abbreviated function name

Either you use $upper with the extension comparison in UPPERCASE

$if($eql('TTA',$upper(%_EXTENSION%)),$repl(%TITLE%,' TTA',' '),)

or you use $lower with the extension comparison in lowercase

$if($eql('tta',$lower(%_EXTENSION%)),$repl(%TITLE%,' TTA',' '),)

Do you want to replace the tta string in all variations like tta, tTa, tTA, TTa, ttA, TTA?
Or what case should be ignored?

Later added warning:

Please don't use this abbreviated syntax!

As found in this bug report, the abbrevation of $repl instead of using $replace can result in unwanted changes. Always use $replace as stated in the help.

1 Like

In $replace() is no fourth optional parameter to ignore the case, in fact
"Functions with variable parameter count (e.g., Replace) are limited to < 64 parameters"

All variants

They are unlikely but can happen, but as I am at it I should address altogether that very rare issue - but adding to the code all variants manually will be a tedious task

You can die only one death: either you use the filter and a plain replace action that ignores the case or you enclose the whole thing in a complicated $IF() but then you have to mention all iterations.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.