Using TAG in actions/combining actions for different tags

I have tried multiple variations but cannot get this to work.

[#0]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' \\(Album\\)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

[#1]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' \\(Digital Album\\)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

[#2]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' \\(EP\\)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

[#3]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' \\(LP\\)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

[#4]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' \\(Single\\)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

Couldn't get it to work in the example you gave either, albeit slightly modified. It executed the code but literally changed the true album and title to literal %ALBUM% and %TITLE%.

[#0]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %TITLE%','[','(',']',')')
1=%ALBUM% \u003d\u003d\u003d %TITLE%

[#1]
T=5
! Replace square brackets with round=
F=_DIRECTORY
1=$replace(A:\\Music\\Record\\%artist%\\%album%,'[','(',']',')')

[#2]
T=5
! Replace square brackets with round=
F=_FILENAME
1=$replace(%TRACK% %TITLE%,'[','(',']',')')

What am I doing wrong?

I do not think that you have to escape the brackets in an ordinary replace action.

Thanks for your reply. Removing the slashes makes no difference, it still does not work.

[#0]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' (Album)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

[#1]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' (Digital Album)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

[#2]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' (EP)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

[#3]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' (LP)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

[#4]
T=7
F=$replace('%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%',' (Single)')
1=%ALBUM% \u003d\u003d\u003d %_DIRECTORY% \u003d\u003d\u003d %_FILENAME%

Can you see anything else wrong with this?

I've been constantly modifying it trying to make it work but just can't find the problem or understand why there is one.

I would test the $replace() statements in Convert>Tag-Tag first
An when you have the correct syntax then use that template for the actions.
I think that you are sometimes missing the replace string, or the number of commas is not right.

Thanks for the reply. I have checked it a gazillion times. To me it looks like each instance includes replace and the correct number of commas (one).

This is the same code unedited, extracted directly from the action file.

$REPLACE('%ALBUM% === %_DIRECTORY% === %_FILENAME%',' (ALBUM)')
%ALBUM% === %_DIRECTORY% === %_FILENAME%

A:\Music\Record\INXS\Kick (Album)\1 Guns in the Sky.mp3
  "" ->
  "Kick (Album) === Kick (Album) === 1 Guns in the Sky"

In this example I am trying to remove " (Album)" from the ALBUM, _DIRECTORY AND _FILENAME. What is the problem?

Just thinking out loud but I wonder if perhaps the following could be a workaround in general for these scenarios:

  1. Formatting the part of the tag that would be affected by the global action in a way that's reversible later in the action
  2. Running the desired formatting on all the tags
  3. Reverting the modifications in the tag you wanted 'excluded'

As an example of modifying the 'excluded' tag's content, using your square brackets replacement in the OP, you could perhaps replace all square brackets in the tag you wanted to 'exclude' with a special Unicode character you know won't be used for anything else, then at the end of the action replacing that Unicode character with the original square brackets.

Hello Lauren, thank you for your reply. I'm not sure why I would remove the square brackets and then put them back, given the desired result is to replace them with round brackets?

My main concern right now is trying to process as many specific tags as possible with the same action rule like in my last post. I just don't understand why it isn't working.

Using your square brackets example, it was a workaround concept for excluding the action from affecting certain tags by changing the tags you want to exclude with different characters so the action doesn't affect them when run, saving the need to copy the replace action formatting for every tag you do want to change.

To visualize let's say the tag you wanted to exclude was Artist, but format all other tags with a square to round bracket replacement.

Original: Example Artist [123]

  1. Formatting using Unicode replacement characters to exclude from later formatting action when run:
    Example Artist ⬔123⬕

  2. Action that changes square brackets to round brackets is run and doesn't affect the Artist tag since the characters were replaced.

  3. A replace format is run to turn the Unicode back to the original characters in the Artist tag:
    Example Artist [123]

Would be trickier for things like excluding certain types of capitalization however.

Thanks for your reply, that could be useful in certain scenarios. I will go through some of my actions and see if that can be applied.

Do you know how I can get this Guess Values, replace example working in my previous post please?

I'm not familiar with the method described by ohrenkino but I'm sure you'll get some further replies with help :slight_smile:

ohrenkino describes the functionality in another post back in December 2017.

The trick is to use an action of the type "Guess value" for the list of fields that you want to treat in one go and use a delimiter of your choice. Also, the bulk function has to be applied to the source.
An example: you want to remove the "The" from ALBUMARTIST and ARTIST:
Action: "Guess value"
Source: $replace('%albumartist%===%artist%,The ,)
Target Pattern: %albumartist%===%artist%
The === can be replaced by more or less any unique character.

I still haven't been able to make it work in my example though.

I understand now. Tested using a slightly modified version of that example and it worked for me (I tested with square to round brackets formatting).

I removed the first ' single quote after the first bracket of the $replace(, making it:

Source format: $replace(%title%===%album%===%artist%,'[','(',']',')')
Guessing pattern: %title%===%album%===%artist%

Found that wrapping the first %title%===%album%===%artist% within the replace function (as seen in ohrenkino's first reply to the topic) in single quotes formatted the fields instead as literal %title% etc.

You do not enter a replace string. You have supplied a data string, a search string but no string what to do with what the function found. It is simply a syntax error.
$REPLACE('%ALBUM% === %_DIRECTORY% === %_FILENAME%',' (ALBUM)',)

Thanks for your reply.

I am not at home to test this but hope it works for me.

To summarise:

Original: ohrenkino

Source: $replace('%title% === %ALBUM%','[','(',']',')')
Target: %title% === %album%

Tested: Me (Not working)

Source: $replace('%ALBUM% === %_DIRECTORY% === %_FILENAME%',' (Album)'
Guessing pattern: %ALBUM% === %_DIRECTORY% === %_FILENAME%

Proposed: LaurenBacall
Replace square brackets

Source format: $replace(%title%===%album%===%artist%,'[','(',']',')')
Guessing pattern: %title%===%album%===%artist%

Me
Remove ' (Album)'

Source format: $replace(%album%===%_directory%===%_filename%,' (Album)')
Guessing pattern: %album%===%_directory%===%_filename%

Can you see a problem with that?

Again: the source has the already mentioned syntax error of no "replace with" part.
And again the advice: you can test these expressions with the function Convert>Tag-Tag
Try it there first please.

I can see that you have highlighted ' (Album)' but I still don't understand why it isn't right when it is converted from the code given by Lauren, which apparently works?

$replace is right at the beginning, how can it be missing?

As you can see from my previous screenshots in post 13 I have been testing in convert tag > tag Using TAG in actions/combining actions for different tags.

The preview should show 'Kick' without ' (Album)' in the example.

My only observation by comparison is that I could have added another comma but the result isn't any different?

$REPLACE(%ALBUM%===%_DIRECTORY%===%_FILENAME%,' (ALBUM)','')

So, to break this down, we are instructing mp3tag to find album, directory and filename and within those tags any instances of ' (Album)'. Does it need another comma like in my example followed by '' to tell it to replace with that?

A:\Music\Record\INXS\Kick (Album)\1 Guns in the Sky.mp3
  "" ->
  "Kick (Album)===Kick (Album)===1 Guns in the Sky"

Yes, if you had added only that ... but you have also added 2 apostrophes.
What happens, if you leave them out?

I thought that as there are apostrophes around ' (Album)' I would have to do the same for any replacement.

The results of removing:

$REPLACE(%ALBUM%===%_DIRECTORY%===%_FILENAME%,' (ALBUM)',)
%album%===%_directory%===%_filename%

A:\Music\Record\INXS\Kick (Album)\1 Guns in the Sky.mp3
  "" ->
  "Kick (Album)===Kick (Album)===1 Guns in the Sky"