Rename file only if extension matches (.Mp3, .Flac, etc)

I am in the process of setting up an Action for renaming recorded podcasts. Each podcast has two files: one lossless (FLAC) and one lossy (MP3).

I wish to rename the FLAC files differently than the MP3 files, so it's easier to differentiate between the lossless and lossy versions.

I found some RegEx on the forum that renames the files based on their creation date, but for the FLAC files I wanted to append the string '[original]' after the RegEx.

I don't personally have a knowledge of RegEx, but I do know that you can include conditional operators ('if'). Does anyone have an answer?

Eg:

MP3:
2012.05.31.mp3

FLAC:
2012.05.31 [original].flac

You did not show the specific Regular Expression, you did talk about, so I assume there is no RegExp involved, but only basic Mp3tag scripting features.

If you want to apply an action to append some data to an existing tag-field content, then the following proposals may help.

  1. Set Filter
    "%_extension%" IS "FLAC"

  2. Use Action
    Action: Format value
    Field: _FILENAME
    Formatstring: %_filename%' [original]'

... or ...

  1. Use Action
    Action: Format value
    Field: _FILENAME
    Formatstring: $if($eql($lower(%_extension%),'flac'),%_filename%' [original]',%_filename%)
    Because %_extension% returns always lower cased names this should work too ...
    Formatstring: $if($eql(%_extension%,'flac'),%_filename%' [original]',%_filename%)

See also:
Actions

DD.20120531.1218.CEST

Thanks so much, works a treat.

As for the Regular Expression, for anyone interested, this is what I'm using:

Action: Format value

Field:
_FILENAME

Format string:
$regexp(%_file_create_date%,(..)/(..)/(....),$3.$2.$1)

Edit: the above format string fails when the Day is a single digit, the following code works instead:

$regexp(%_file_create_date%,(\d\d?)/(\d\d?)/(\d\d\d\d),$3.$2.$1)

I'm working on a better solution, as using the File Creation Date timestamp is unreliable, it changes when the file is copied to a different location.

See also:
writing file creation date to tag with this format : YYYYMMDD (year, month, day)

If you set your system's date time display according to ISO 8601, then you do not need to convert the file's creation date tíme, that means %_file_create_date% will return immediately '2012-05-31'.

DD.20120531.1252.CEST