Tag field only if filename contains a specific string using an action

Hello, I've been using Mp3Tag for while now, and I was wondering if its possible to make an action that will format a value only if the filename has a specific string in it. My main goal is to have an action to tag my large archive of radio shows based on the filename. Right now, I have actions for each separate radio show, but I would like to be able to simultaneously tag a selection of different show at the same time.

For example, say I have three files -

ShowA - 2012-05-07.mp3
ShowB - 2012-07-12.mp3
ShowC - 2012-06-21.mp3

A part of the action could tag the Genre field in each file to -


I would want the artist field to be formatted with a different artist as well, depending on the show in the filename.

Is this even possible, maybe using if,then,else expressions? I tried reading the help document on expressions, but I couldn't really find any examples specifically for this. Thanks in advance.

This is for ShowA -> Genre=Political

Action type: Format value
Field: GENRE
Format string: $if($eql($strstr(%_filename%,ShowA),1),Political,%genre%)

It means if the string ShowA is found at the first position of the filename, write Political in the genre. If not keep the old genre value.

Hey, thanks for the quick reply man. :slight_smile: I will have to try that. Will this work for shows with spaces? Also how would I extract the year from the filename if the format is "Show - YYYY-MM-DD"? Without an action type for that, I would need to make an action for each year.

Extracting the year:

Action type: Guess values
Source format: $regexp(%_filename%,'^.+(\d\d\d\d)-(\d\d)-(\d\d).*',<$1>)
Guessing pattern: <%year%>

Hey thanks for all the help. Since all of my radio shows are consistent, thanks to a handy program called Advanced Renamer, I ended up using %album% - %year%-%dummy%-%dummy% to get the album from the show name and also the year. I'm pretty happy now with my setup, so for those curious I'll share my action setup for tagging radio shows.

For example, for just a show called "Howard Stern Radio Show"

Action type: Remove fields

Action type: Format value
Field: TITLE
Format string: %_filename%

Action type: Format value
Format string: $if($eql($strstr(%_filename%,Howard Stern Radio Show),1),Howard Stern,%artist%)

Action type: Format value
Format string: %artist%

Action type: Format value
Field: GENRE
Format string: Radio

Action type: Format value
Format string: $if($eql($strstr(%_filename%,Howard Stern Radio Show),1),www.howardstern.com,%comment%)

Action type: Guess Values
Source format: %_filename%
Guessing pattern: %album% - %year%-%dummy%-%dummy%

So, for multiple radio shows, the only tags that need an if expression is the artist and comment. The comment is the show's website. I found you can have multiple if statements in the same Format value entry, instead of needing multiple entries, for multiple shows. Also I decided to just have the genre be Radio for all of the shows.