Rename Folders with MP3 or FLAC indicator

I want to rename Folder/Directory in the format

ABC-1990-Absolutely [FLac] [17] [Y]

%albumartist% - [%year% - ]%album% %extension% %_total_files% %filetype% %_covers% %_filename_ext%

I dont know whether i need filename_ext or filetype to indicate MP3 or FLAC.

I also tried '[]' to get items in square brackets without sucess.

How can i make covers a yes or no rather than a number?

What does %_counter% do?

Thanks for any assistance.

  1. Read the Mp3tag Help Manual.

  2. Use this Testfile:
    richmail.mp3 (2.08 KB)

  3. Try the following example, which changes the filename, to understand the principle.

Convert | Tag - Filename | ALT+1

Select format string

Format string:

%ALBUMARTIST%'-'%YEAR%'-'%ALBUM%' ['%_extension%'] ['%TOTALTRACKS%'] '$ifgreater(%_covers%,0,'[Y]','[N]')

ABC-1990-Absolutely [mp3] [17] [N].mp3

  1. Then try again to change the Foldername.

Convert | Tag - Filename | ALT+1

Select format string

Format string:
'..'%albumartist%'-'%year%'-'%album%' ['%_extension%'] ['%totaltracks%'] '$ifgreater(%_covers%,0,'[Y]','[N]')''%_filename%

..\ABC-1990-Absolutely [mp3] [17] [N]\richmail.mp3

"O:\TEST\T1\richmail.mp3" ->
"O:\TEST\ABC-1990-Absolutely [mp3] [17] [N]\richmail.mp3"


richmail.mp3 (2.08 KB)

Action: Format Value
%albumartist%-%year%-%album% '['%_extension%']' '['%_total_files%']' '['$if($grtr(%_covers%,0),Y,N)']'


%albumartist%-%year%-%album% '['%_extension%']' '['%_total%']' '['$if($grtr(%_covers%,0),Y,N)']'

the first formatstring gets you the number of total files from the number of files you have selected. the second gets it from the tracknumber if it is stored in the format tracknumber/totaltracks e.g. 1/17 , 2/17 ,...

it's %_extension%

its '['...']'

$if($grtr(%_covers%,0),Y,N) gives you Y for one or more covers and N for no cover.

%_counter% gives every file a new number at the same field if you format more files. It's useless if you format the directory because in this special case it's always the first file from which the values are taken, so the counter would always be 1 (unless you format more than one folder ins one go). It can be usefull if you want the titles to be called simply track 1, track 2, track 3, you would use "track %_counter%" in this case.

here is a oversight of the placeholders:

Pone and DevlevD

Thank you both very much.

I am going blind and with the date shown if varible, i missed the second ' . Anyhow your examples were excellent.

The clarification of %_extension% and the difference between total and totaltracks was great. This sort of stuff should be explained in the user guides. You saved me another 4 hours of searching and eye killing strain.

Anyhow my new folder specification is

%albumartist% - [%year% - ]%album% '['$upper(%_extension%)']' '['%_total_files%']'['['%_total%']'] '['$if($grtr(%_covers%,0),Y,N)']'

ABC - Absolutely [FLAC] [17][17] [Y]

And i never needed the counter here at all.

Thanks again :rolleyes: :rolleyes:

Hi everyone I am trying to do the same thing by using these instructions but I can only changed the file names not the folder names. what could be wrong?

What do you exactly do?
Do you use an action of the type "Format Value" for _DIRECTORY or do you use the converter TAG->Filename?

Well for the beginning I managed to do the add FLAC or MP3 to the folder name by using the code below in the action section.
%ARTIST%'-'%YEAR%'-'%ALBUM% '('$upper(%_extension%)')'

but what I want to add is;
1-if there is no %albumartist% use %artist% tag
2- Rename the folder if files are only MP3
3-adding bit depth and sampling frequency to the flac album folder name such as "Opeth-2004-Damnation [16-44] " instead of adding (FLAC) to file name.

by the way is there any guide or detailed help file with all possible statements and actions with explanations. Especially I want to learn how to use if statement.

You will find all the script commands here:
There are several IF commands and some other boolean functions.

Thank you, for the beginning it would be great if anyone help me to solve above problem. I can learn quite a lot from analyzing the above code.

Which part of code exactly do you want to have explained?

Dear LyricsLover, I want to learn how to do this section especially.

3-adding bit depth and sampling frequency to the flac album folder name such as "Opeth-2004-Damnation [16-44] " instead of adding (FLAC) to file name.

In a first step you need to find the placeholders for "bit depth" and "sampling frequency".
If you look here:
you will find possible matches with %_bitrate% and %_samplerate%
Maybe you look for %_bitspersample%

Please check, if this are the correct one.

With the matching placeholders you can build your action and replace the '('$upper(%_extension%)')' part with your new found placeholders.

You may find some additional hints in this existing thread:

Please let us know, how your final format string looks like.

I reach my goal on the FLAC bits per sample and sample rate information. I am writing my experience as a tutorial for anyone need this type of Action.

First I tried the suggestions of @LyricsLover
%ARTIST%'-'%YEAR%'-'%ALBUM% '('$upper(%_extension%)')' '('%_samplerate%')' :

Ahkmed-2009-Distance (FLAC) (44100)

%ARTIST%'-'%YEAR%'-'%ALBUM% '('$upper(%_extension%)')' '('%_bitrate%')' :

Ahkmed-2009-Distance (FLAC) ( 836)

%ARTIST%'-'%YEAR%'-'%ALBUM% '('$upper(%_extension%)')' '('%_bitspersample%')'

Ahkmed-2009-Distance (FLAC) (16)

SUCCESS for the bits per sample :slight_smile:

As you can see in the above sample rate case it will write the long value of the sample rate as "44100" but what I want to write is "44". In the forum I have this code to obtain my purpose

$cutRight(%_samplerate%,3)$trimRight('.'$right(%_samplerate%,3),'.0')' kHz'

48000 ==> 48 kHz
44100 ==> 44.1 kHz
22050 ==> 22.05 kHz
12000 ==> 12 kHz

I used this value

%ARTIST%'-'%YEAR%'-'%ALBUM% '('$upper(%_extension%)')' '('%_bitspersample%'-'$cutRight(%_samplerate%,3)$trimRight('.'$right(%_samplerate%,3),'.0')' kHz'')'

then I get

Ahkmed-2009-Distance (FLAC) (16-44.1 kHz)

What I want to do is now delete the kHz section as given below

%ARTIST%'-'%YEAR%'-'%ALBUM% '('$upper(%_extension%)')' '('%_bitspersample%'-'$cutRight(%_samplerate%,3)$trimRight('.'$right(%_samplerate%,3),'.0')')'

Ahkmed-2009-Distance (FLAC) (16-44.1)

Maybe I need to modify the code to write just 44 instead of 44.1 for the sample rate.

%ARTIST%'-'%YEAR%'-'%ALBUM% '('$upper(%_extension%)')' '('%_bitspersample%'-'$cutRight(%_samplerate%,3)')'

Ahkmed-2009-Distance (FLAC) (16-44)

:+1: :+1: :grin:

1 Like

I can continue to second part of my question after solving this one. What I want to do is adding (MP3) to the folder name. In the above code %_extension% will add flac or mp3 to the folder name. But what I want to do is

-add extension to the folder name if files are MP3. For this I should definitely use "if" statement and for that definitely I need some help.

I have found this but I could not make it work

You can test your expressions in Convert>Tag-Tag where the preview shows you the probably result.
Please note that the functions are case sensitive.
Right now your expression has a statement only for the FALSE case.

Thank you. I correct the code but now I am having a bigger issue about the hidden files.

Due to the Macos operating system in the folders I have 4 kb hidden files named ._SOMETHING

because of these files folder naming fails because mp3tag reads these files as flac file with empty tag fields therefore folder names become

-- (FLAC) [-]

Is there any way to avoid these files for an action ? Maybe an if condition can be used to limit file size higher than 10 kb but I have no idea to use multiple if conditions in one action.

Why don't you just define a filter prior to use the action, i.e.
%_file_size_kb% GREATER 10

Where should I add this code ?, I am new to actions. like this one ?

%_file_size_kb% GREATER 10 %ARTIST%'-'%YEAR%'-'%ALBUM% $if($eql(%_extension%,'FLAC'),"("$upper(%_extension%)")" '['%_bitspersample%'-'$cutRight(%_samplerate%,3)']','('$upper(%_extension%)')')

I was not talking of integrating my example into the action but simply use the filter box, which if you don't see it can if shown with F3.