String function prevents formatting _DIRECTORY on multiple files

Thanks for updating Mp3Tag to 3.26. After updating, I noticed a change in behavior on an Action I use. First, I'll explain how I use it.

I have media files in separate folders. I want to rename the files, then move all of them to the parent directory. Each of the separate folders are eliminated.

G:\Folder A\Folder 1\song1.mp3
G:\Folder A\Folder 2\song2.mp3
G:\Folder A\Folder 3\song3.mp3

The Action:

Format value "_FILENAME": $validate(%album% - %title%$if($grtr($len(%artist%),0), - %artist%,),-)
Format value "_DIRECTORY": $validate($left(%_path%,$sub($sub($strrchr(%_path%,'\'),1), $len(%_directory%))),-)

Results in:

G:\Folder A\song1renamed.mp3 (using a basic filename here, to keep it simple)
G:\Folder A\song2renamed.mp3
G:\Folder A\song3renamed.mp3

To "move" the files to the parent folder, the Action modifies the _DIRECTORY information field. The command looks at the current directory of the file and ignores the last folder in the hierarchy. Doing this automatically "deletes" the folder, too.

This Action still works properly in v3.26, but it no longer runs on all selected files. After changing the filename and directory of the first selected item, it stops.

I tried to narrow it down by finding when "format value" stops working on multiple files.

Using the basic "Tag - Tag" converter, I discovered that simply using $strrchr(%_path%,'\') as a format string on the _DIRECTORY field prevents the operation from running on multiple selected files.

The Tag-Tag converter preview correctly shows the result of $strrchr(%_path%,'\') on all selected files. But when I apply, the directory is only changed on the first selected file.

If instead of formatting _DIRECTORY, I instead format _FILENAME, all selected files have their filenames changed to the value of $strrchr(%_path%,'\') The issue is specific to formatting _DIRECTORY.

I'm using the 64-bit version of v3.26 on Windows 11.

Thank you for reporting! It's quite tricky and I'll probably need the next week to fix it.

It's most likely not only the first selected file, but the all the files of the first renamed subfolder that are moved.

I'll keep you posted.

This should be fixed with Mp3tag v3.26a.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.