Conditional folder renaming

Right now I use this Format Value action to rename a folder:

Format string: %album% '['$upper(%_extension%)']'

Example: \Album title [FLAC]\File.flac

What I would like to do is write an action that would use this format only if there is already a folder with the same name as %album% in the grandparent folder. If not, then it woul use just album name without the extension.

I think that it would require one of the Boolean functions but I don't know how to describe it.

Mp3tag can't determine if a folder already exists. It can only read the parent and grandparent folder names. If the album were already in the appropriate grandparent folder, then you could do a conditional folder renaming with

Action type: Format value
Format string: %album%$if($eql($upper(%_extension%),%_parent_directory%),' ['$upper(%_extension%)']',)

I'm sorry, I can't decipher what that string would do. Add the extension to folder name if the grandparent directory is named like uppercased extension? :unsure:

Yes. Actually, there was a mistake. It should be:

Action type: Format value
Format string: %album%$if($eql($upper(%_extension%),%_parent_directory%),' ['$upper(%_extension%)']',%_directory%)

But I see that I misread your post. You wanted this action to disambiguate the folder names for matching albums.

Exactly. But if mp3tag can't check the names of the folders that aren't part of the album path that's all right. I'll just continue using my current action.

Yes. Mp3tag currently provides no $FileExist() or $FolderExist() functions.

Yes, but not quite right.
Mp3tag provides two system related pseudo tag-fields ...
%_directory% ... the name of the home folder of the media file;
%_parent_directory% ... the name of the folder of the home folder of the media file.

Beside that it is possible to evaluate the complete folderpath, for each folder item, by using the Mp3tag scripting language and actions as described there ...
Easy way to get directory names above Parent?
unterschiedlicher Aufbau von Dateinamen


Hm, maybe ...

$if($eql(%_parent_directory%,%ALBUM%' ['$upper(%_extension%)']'),%ALBUM%' ['$upper(%_extension%)']'),%ALBUM%)


Detlev, does your string mean that if grandparent directory is named "Album [EXT]", then parent directory would also be named "Album [EXT]", otherwise it would be named just "Album"?

Yes, I do read the expression the same way too.
aax, I admit that I did not fully understand the problem and have therefore given only one thinking incentive.
It is not clear to me, what the "parent directory" or the "directoy" will be searched for, and what should be changed in the "directory".
It would be helpful if you can show an example of the two cases in their directory tree structure.