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?



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:


Thanks so much, works a treat.

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

Action: Format value


Format string:

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


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'.