Combining 'replace with' [empty] in multiple fields action


#1

@ryerman
This is a follow-on to my previous thread.

I have a list of words which I want to search for in several fields, including ALBUM, DIRECTORY and FILENAME and then remove.

image

Could you please tell me whether you can think of a way to make this happen in less lines than currently displayed? The less the better.

Thank you for your help as always.


#2

The other way around?
Do you have fields where you want to keep (Album), (Digital Album), (EP), (LP), (Single)?
If not:
You could remove it from _ALL instead of ALBUM, _DIRECTORY and _FILENAME


#3

Hasn't all this been discussed in this thread?

Why the double-post?


#4

Thanks for your replies.

@LyricsLover
The intended use is to keep this within an all-in-one action group.

If I add this action to the beginning it would be possible to make it work as you have suggested.

If I were to do this, I could reduce the number of lines from 15 to 5 (which is a pretty good improvement).

Is there a way to condense further?

@ohrenkino
Whilst the code worked to change square brackets to round, the action could not be adapted for use in other circumstances so, based on @ryerman's recommendation (like in the other thread mentioned) I have started a new thread for this question because the previous question was unclear and did not resolve the query. Now this is related to a different specific example.


#5

3 lines, 1 for each field, like this:

Action: Format value
Field: _DIRECTORY
Format String: $replace(%_directory%, '('Album')',, '('Digital Album')',, '('EP')',, '('LP')',, '('Single')',)

Or
This action group, which has 6 lines but may be easier to read and edit.

Remove specified string in ALBUM, _DIRECTORY, _FILENAME.mta (380 Bytes)

Have you ever heard these old sayings:
"If it ain't broke, don't fix it."
or
"Perfect is the enemy of good."

I appreciate your desire to reduce the number of lines in your action groups, but sometimes the effort is not worth the benefit! :slightly_smiling_face:


#6

Just to add the "Guess value" example:
Action: Guess value
Source: $replace(%_directory% == %_filename% === %album%, '('Album')',, '('Digital Album')',, '('EP')',, '('LP')',, '('Single')',)
String: %_directory% == %_filename% === %album%

There is no guarantee that it actually works with this combination of fields as I still suspect that you have to run actions that manipulate the folder name in a different action group.


#7

@ohrenkino
Thanks for providing an alternative solution. I tested it but it didn't pick up (ep) from any fields mentioned unless the case matched exactly as specified in the example given.

There does appear to be a limitation with this method whereby the directory name is not affected.

Interestingly (and frustratingly), when saving changes through mp3tag to the example you have given in the action manager it keeps changing the case of the words included to 'First Letter Of Each Word'.


#8

@ryerman
Thank you for your suggestions. I can confirm that I tested the first suggested and it worked perfectly regardless of case used.

Can this be used with _TAG? I can't make that work in testing:

image

It does not affect case. Neither does _ALL.

Listing them all out makes a difference except to 'ALBUM ARTIST'

Not sure why that is?


#9

My guess: Because _TAG and _ALL are not allowed as the Field in a "Format Value" action.

There is no default field called ALBUM ARTIST in Mp3tag. Use ALBUMARTIST, without a space.


#10

Thank you for confirming both points.

The problem was 'Album Artist' not being 'AlbumArtist'.

I presume _TAG or _ALL can be incorporated into this by using regex replace?


#11

Yes. You can tell they are allowed because they are hard-coded into the drop-down list of the "Replace with regular expression" action, unlike in the "Format value" action.

Try it and see.


#12

I tried replacing the several fields with _ALL using regexp and the action did not work.

It seems to only work when the major fields/file attributes are dictated?

I tried to use %_ALL% instead of %ARTIST% within the brackets but this made no difference?


#13

After further testing it looks like this is case sensitive too. I input the test in lower case, save the action and then it converts the code to Mixed Case...


#14

Yes. We have discussed this before. And I bet that LP does not work either as I suspect that you run an action before that which sets the first letter to upper case and the others to lower. "Album", "Digital Album" and "Single" follow these rules.
So it should be a piece of cake to add the pairs for "Lp" and "Ep".
I assume that the $replace() in a "Format value" action behaves in the same way.


#15

It appears that you are falling back on old bad habits: copying solutions without knowing the basics.
I'm not sure what your regular expressions match, but matches will be deleted!
You want them changed to UPPER case.

Try this:

Action: Replace with regular expression
Field: _ALL
Regular expression: (?i)\b(abba|adda|absrdst|acdc|ac dc|akdong musician)\b
Replace matches with: \U$1\E

I've shown a partial artist list: replace it with what you want.
ARTIST_LIST is not needed.


#16

You may have changed case somewhere else, but that "Format value" action has nothing to do with converting case.

A replace action can be case sensitive or case-insensitive.
The replace function, $replace(string,from,to), is always case sensitive.


#17

Thank you both for your replies. I am sorry that I have not got back to you sooner. Not had a chance to test your suggestions yet, but will be sure to try them out when I get an opportunity.

In the mean time, I am attaching all my actions (mainly for my benefit in case I lose them, but also in case anyone is interested/they are helpful). The one which most closely relates to what has been discussed before your two most recent suggestions is called All In One Conversion (Record Folder) Filename & Directory.mta.

They may be useful to others, so long as you know that my workflow involved keeping new artists/albums in a folder within A:\Music\Record for processing in Mp3tag (filename changes to # Trackname with correct capitals in all tags). Even if the folder structure is not correct, so long as the artist name is included when processing, it will correct this for you to A|\Music\Record\Artist\Album. Once completed, I run Finished Tagging (Move to Music).mta to move the new Artist\Album to A:\Music\Artist\Album. I then run 'Remove Empty Directories' (http://www.jonasjohn.de/red.htm) to clear the empty folders in A:\Music\Record using the following settings:

Mp3tag is a crazy good timesaver for doing a lot of manual work which used to take days and now takes minutes!

actions.zip (28.6 KB)