Show mp3 genre in FOLDER InfoTip?

Hello,

I am trying to get Directory Opus to show the MP3-Genre tag already in the Folder InfoTipp.

Simply putting {mp3genre} in the Folder infoTipp does not work.

I understand it might be difficult due to the possibility of having different genres tagged in the folder.
But only reading out the genre from the first mp3 in one folder would be sufficient to me.

Is there a way to accomplish this?

Many thanks in advance,
Robert

You could do it with a custom script column but there's nothing built-in for that. Genre is a property of each music file, not the folder that contains them.

Okay, thanks for the info.
Unfortunately I cannot script...

This add-in should do what you want.

function OnInit(initData) {
    initData.name = 'FolderMp3Genre';
    initData.version = '2021-06-12';
    initData.copyright = '';
    initData.url = 'https://resource.dopus.com/t/show-mp3-genre-in-folder-infotipp/38688';
    initData.desc = '';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

function OnAddColumns(addColData) {
    var col = addColData.AddColumn();
    col.name = 'FolderMp3Genre';
    col.label = 'FolderMp3Genre';
    col.header = 'FolderMp3Genre';
    col.justify = 'right';
    col.autogroup = true;
    col.method = 'OnColumn';
}

function OnColumn(scriptColData) {
    var item = scriptColData.item;
    if (!item.is_dir) return;
    if (item.path.drive == 0) return;

    var foundTag = false;
    var fsu = DOpus.FSUtil();
    var folderEnum = fsu.ReadDir(item);
    while (!folderEnum.complete) {
        var folderItem = folderEnum.Next();
        if (folderItem.metadata == 'audio') {
            var genre = folderItem.metadata.audio.mp3genre;
            if (genre == '') continue;
            foundTag = true;
            break;
        }
    }

    scriptColData.value = foundTag ? genre : 'no audio file inside';
}

ColumnFolderMp3Genre.js.txt (1.2 KB)

How to

How to use buttons and scripts from this forum

2 Likes

@lxp: Many thanks! It works like a charm and exactly like needed :slightly_smiling_face:

This kind of support is why Directory Opus is truely great!

Hi, this script above seems be have been broken, is it maybe due to me upgrading to Directory Opus 13 (13.10 to be precise)?

All I get is the "no audio file inside" error message though each folder contains mp3 files with genre-metadata embedded.

Many thanks in advance.

The script still works fine here, and I can't think of anything in Opus 13 that might break it.

Have you tried adding the column to the file display? Do you never get any results? Have you moved files to subfolders? The script doesn't read folders recursively.

Can you share a file containing a genre field that goes undetected by the script? I am happy to try it out.

Hello,

thanks for your reply. I will try to answer your questions:

Yes, I am aware that the script does not read sub-folders, for folders with subfolders within the error message "no audio files inside" is expected.

Here is a screenshot of a bunch of ´sample folders that have audio files in there, where the "genre" field works correctly, but the custom script not.

here with extended view:

Here is one of the mp3 files as test so you can see that the mp3 tags should be assigned correctly:
Elektrokill - 07 - Sadile.zip (1.5 MB)
(zipped it so I can upload it)

I tried many folders, files and drives, there seems to be currently only one folder where I see a FolderMp3Genre, here:

The inside of the folder looks like this:

Do you have any idea how this could be fixed?

At first I thought it might be a permissions thing but then this one exemption would not show up...

From reading the code, what can happen is that the files have multiple metadata streams and audio is not the primary metadata.

It's not tested but, you could try and replace :

        if (folderItem.metadata == 'audio') {

with :

        if (folderItem.metadata.audio != undefined) {

Yes, this change seems to have worked, thank you!

I don't know why the change was neccesary, since it was working before, but well, it works again.

Thanks again!

1 Like

Well, how odd!

Here the script runs fine with the demo file :confused:

I also tried the script on Win10 without problems.

At least now we know where to look :relieved: