$if Artist - Title (Mix) [Publisher]

I'm hoping someone can help me create an "IF" argument to generate tag fields based upon the structure of the filename, for example:
"K Klass - Rhythm Is A Mystery (Percussion Mix) [Deconstruction]"

Would become:
"Artist - Title (Mix) [Publisher]"

If the [Publisher] is not present then parse as "Artist - Title (Mix)"

I've tried the below using "Import tag fields", the first part is successful but the second part without the publisher fails.
$ifeql($strstr(%_FILENAME%,%DUMMY% - %DUMMY% (%DUMMY%) [%DUMMY%]),0,%ARTIST% - %TITLE% (%MIXARTIST%) [%PUBLISHER%],%ARTIST% - %TITLE% (%MIXARTIST%))

Any help is appreciated.

I think that you have to use a filter to get the data from the filenames with different patterns.
e.g.
%_filename% HAS "["
for the ones with the publisher and
NOT %_filename% HAS "["
for the ones without.

Please note that %dummy% only works in matching format strings but the scripting function has to generate a format string first, so that is a generating format string.

You could try an action of the type "Import fields" with
Source: $if($grtr($strstr(%_filename%,'['),0),$regexp(%_filename%,'(.*) - (.*) \((.*)\) \[(.*)\]',$1==$2==$3==$4),$regexp(%_filename%,'(.*) - (.*) \((.*)\)',$1==$2==$3==))
Target format string: %artist%==%title%==%mixartist%==%publisher%

If there is no data in the square brackets, no data i written to %publisher% and as empty fields do not exist, it will not be included in the file.

Thank you very much, that works exactly as expected. :pray:

Do you know if there a way to retain the information in the fields containing data that aren't targeted by "%artist%==%title%==%mixartist%==%publisher%", or is this an unfortunate side effect of the process?

Thanks again.

I don't know what you mean.
When you import data into fields, only these get modified and those which were filled before, are kept.

Unfortunately it wipes the other fields as seen in the screenshots:

Before

After

No big deal, I'll try and work with it if it's part and parcel.

What kind of files are these?
MP3?
Do they have APE tags?
Which tags do you read and write?

They're 320 .mp3 files, i'm not aware of them having APE tags.

Basically my workflow is to

  1. Strip most of the data from the files other than filename, beatport track id and a few other fields.
  2. Run through One Tagger to gather the relevant track information and add any tags such as mood and instrumentation.
  3. Run through mixed in key.
  4. Final tidy up in mp3tag.
  5. Import into Rekordbox.

The main tags i read and write are filename, artist, title, mixartist, publisher, comments.

If you have a column that shows the tag and the read tags, you might find the string APE.

Or apply a filter with
%_tag% HAS APE
and see if any files pop up.

My tags read as ID3v2.3 (ID3v1 ID3v2.3)

OK, now I am out of clues - perhaps some folks that know Macs better can help.

Thank you very much for your help, it's sincerely appreciated. :blue_heart:

I've just double-checked and it doesn't wipe the fields — this would be an issue that needs fixing.

Can you check that none of the other steps wipe the fields, and if not, the Tag-writing settings are similar to

Sorry for delayed response.

The above solution provided by ohrenkino does now indeed work as intended.
I removed all actions I had created and rebuilt them. Just to close off with your post, my tag type settings are set as shown in the screenshot also.

Thank you both your help. :blue_heart: