Help - Search - Members - Calendar
Full Version: Rename file only if extension matches (.Mp3, .Flac, etc)
Mp3tag Forums > Mp3tag - International > Support
LaurenBacall
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

DetlevD
QUOTE (LaurenBacall @ May 31 2012, 10:35) *
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 ... for the FLAC files I wanted to append the string '[original]' after the RegEx.
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:
http://forums.mp3tag.de/index.php?showtopi...post&p=4109

DD.20120531.1218.CEST
LaurenBacall
QUOTE (DetlevD @ May 31 2012, 20:19) *
1. Use Action
Action: Format value
Field: _FILENAME
Formatstring: $if($eql($lower(%_extension%),'flac'),%_filename%' [original]',%_filename%)



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.
DetlevD
QUOTE (LaurenBacall @ May 31 2012, 12:34) *
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)

See also:
http://forums.mp3tag.de/index.php?showtopi...ost&p=50621

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
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.