Mp3 Tag File

This script, inspired by @Steve link , allows you to edit the metadata of a single Mp3 file.

01

To install it, just download it:
Mp3 Tag File.js.txt (16.4 KB)

And copy it to:
"/dopusdata\Script AddIns"

Once installed, we only have to create a button with the Mp3TagFile command.

The musical genres present in the "Genre" drop-down list are those of Opus, located in /dopusdata\ConfigFiles\musicgenres.xml

However, this list can be edited to individual taste, adding or eliminating genres. To do this, just go to Preferences > Toolbars > Scripts and click on the Scripts Management link, or directly access this window through a button with the command Prefs PAGE=scripts. Once in this window, just locate the script (Mp3 Tag File) and click on the gear shaped icon.

04

Before finishing, I want to once again express my eternal gratitude to @errante, @lxp and @WKen, three giants of programming, for all the help provided, without whom the creation of this script would not have been possible!!!

// Mp3 Tag File
// (c) 2024 DASOTA
// Script para Directory Opus.

var configName = "genre";

function OnInit(initData) {
    initData.name = "Mp3 Tag File";
    initData.version = "1.0";
    initData.copyright = "(c) 2024 DASOTA";
    initData.desc = "Mp3 Tag File";
    initData.default_enable = true;
    initData.min_version = "13.0";

    initData.config_desc = DOpus.Create.Map();
    initData.config_desc(configName) = "Add/remove music genres";

    var genero_pre = DOpus.NewVector();

    genero_pre.push_back = "A Cappella";
    genero_pre.push_back = "Abstract";
    genero_pre.push_back = "Acid";
    genero_pre.push_back = "Acid Jazz";
    genero_pre.push_back = "Acid Punk";
    genero_pre.push_back = "Acoustic";
    genero_pre.push_back = "Afro-Punk";
    genero_pre.push_back = "Alt. Rock";
    genero_pre.push_back = "Alternative";
    genero_pre.push_back = "Ambient";
    genero_pre.push_back = "Anime";
    genero_pre.push_back = "Art Rock";
    genero_pre.push_back = "Audio Theatre";
    genero_pre.push_back = "Audiobook";
    genero_pre.push_back = "Avantgarde";
    genero_pre.push_back = "Ballad";
    genero_pre.push_back = "Baroque";
    genero_pre.push_back = "Bass";
    genero_pre.push_back = "Beat";
    genero_pre.push_back = "Bebop";
    genero_pre.push_back = "Bhangra";
    genero_pre.push_back = "Big Band";
    genero_pre.push_back = "Big Beat";
    genero_pre.push_back = "Black Metal";
    genero_pre.push_back = "Bluegrass";
    genero_pre.push_back = "Blues";
    genero_pre.push_back = "Booty Bass";
    genero_pre.push_back = "Breakbeat";
    genero_pre.push_back = "BritPop";
    genero_pre.push_back = "Cabaret";
    genero_pre.push_back = "Celtic";
    genero_pre.push_back = "Chamber Music";
    genero_pre.push_back = "Chanson";
    genero_pre.push_back = "Chillout";
    genero_pre.push_back = "Chorus";
    genero_pre.push_back = "Christian Gangsta Rap";
    genero_pre.push_back = "Christian Rap";
    genero_pre.push_back = "Christian Rock";
    genero_pre.push_back = "Classic Rock";
    genero_pre.push_back = "Classical";
    genero_pre.push_back = "Club";
    genero_pre.push_back = "Club-House";
    genero_pre.push_back = "Comedy";
    genero_pre.push_back = "Contemporary Christian";
    genero_pre.push_back = "Country";
    genero_pre.push_back = "Crossover";
    genero_pre.push_back = "Cult";
    genero_pre.push_back = "Dance";
    genero_pre.push_back = "Dance Hall";
    genero_pre.push_back = "Darkwave";
    genero_pre.push_back = "Death Metal";
    genero_pre.push_back = "Disco";
    genero_pre.push_back = "Downtempo";
    genero_pre.push_back = "Dream";
    genero_pre.push_back = "Drum & Bass";
    genero_pre.push_back = "Drum Solo";
    genero_pre.push_back = "Dub";
    genero_pre.push_back = "Dubstep";
    genero_pre.push_back = "Duet";
    genero_pre.push_back = "Easy Listening";
    genero_pre.push_back = "EBM";
    genero_pre.push_back = "Eclectic";
    genero_pre.push_back = "Electro";
    genero_pre.push_back = "Electroclash";
    genero_pre.push_back = "Electronic";
    genero_pre.push_back = "Emo";
    genero_pre.push_back = "Ethnic";
    genero_pre.push_back = "Euro-House";
    genero_pre.push_back = "Euro-Techno";
    genero_pre.push_back = "Eurodance";
    genero_pre.push_back = "Experimental";
    genero_pre.push_back = "Fast-Fusion";
    genero_pre.push_back = "Folk";
    genero_pre.push_back = "Folk-Rock";
    genero_pre.push_back = "Folklore";
    genero_pre.push_back = "Freestyle";
    genero_pre.push_back = "Funk";
    genero_pre.push_back = "Fusion";
    genero_pre.push_back = "G-Funk";
    genero_pre.push_back = "Game";
    genero_pre.push_back = "Gangsta Rap";
    genero_pre.push_back = "Garage";
    genero_pre.push_back = "Garage Rock";
    genero_pre.push_back = "Global";
    genero_pre.push_back = "Goa";
    genero_pre.push_back = "Gospel";
    genero_pre.push_back = "Gothic";
    genero_pre.push_back = "Gothic Rock";
    genero_pre.push_back = "Grunge";
    genero_pre.push_back = "Hard Rock";
    genero_pre.push_back = "Hardcore";
    genero_pre.push_back = "Heavy Metal";
    genero_pre.push_back = "Hip-Hop";
    genero_pre.push_back = "House";
    genero_pre.push_back = "Humour";
    genero_pre.push_back = "IDM";
    genero_pre.push_back = "Illbient";
    genero_pre.push_back = "Indie";
    genero_pre.push_back = "Indie Rock";
    genero_pre.push_back = "Industrial";
    genero_pre.push_back = "Industro-Goth";
    genero_pre.push_back = "Instrumental";
    genero_pre.push_back = "Instrumental Pop";
    genero_pre.push_back = "Instrumental Rock";
    genero_pre.push_back = "Jam Band";
    genero_pre.push_back = "Jazz";
    genero_pre.push_back = "Jazz+Funk";
    genero_pre.push_back = "JPop";
    genero_pre.push_back = "Jungle";
    genero_pre.push_back = "Krautrock";
    genero_pre.push_back = "Latin";
    genero_pre.push_back = "Leftfield";
    genero_pre.push_back = "Lo-Fi";
    genero_pre.push_back = "Lounge";
    genero_pre.push_back = "Math Rock";
    genero_pre.push_back = "Meditative";
    genero_pre.push_back = "Merengue";
    genero_pre.push_back = "Metal";
    genero_pre.push_back = "Musical";
    genero_pre.push_back = "National Folk";
    genero_pre.push_back = "Native American";
    genero_pre.push_back = "Neoclassical";
    genero_pre.push_back = "Neue Deutsche Welle";
    genero_pre.push_back = "New Age";
    genero_pre.push_back = "New Romantic";
    genero_pre.push_back = "New Wave";
    genero_pre.push_back = "Noise";
    genero_pre.push_back = "Nu-Breakz";
    genero_pre.push_back = "Oldies";
    genero_pre.push_back = "Opera";
    genero_pre.push_back = "Other";
    genero_pre.push_back = "Podcast";
    genero_pre.push_back = "Polka";
    genero_pre.push_back = "Polsk Punk";
    genero_pre.push_back = "Pop";
    genero_pre.push_back = "Pop-Folk";
    genero_pre.push_back = "Pop-Funk";
    genero_pre.push_back = "Porn Groove";
    genero_pre.push_back = "Post-Punk";
    genero_pre.push_back = "Post-Rock";
    genero_pre.push_back = "Power Ballad";
    genero_pre.push_back = "Pranks";
    genero_pre.push_back = "Primus";
    genero_pre.push_back = "Progressive Rock";
    genero_pre.push_back = "Psybient";
    genero_pre.push_back = "Psychedelic";
    genero_pre.push_back = "Psychedelic Rock";
    genero_pre.push_back = "Psytrance";
    genero_pre.push_back = "Punk";
    genero_pre.push_back = "Punk Rock";
    genero_pre.push_back = "R&B";
    genero_pre.push_back = "Rap";
    genero_pre.push_back = "Rave";
    genero_pre.push_back = "Reggae";
    genero_pre.push_back = "Retro";
    genero_pre.push_back = "Revival";
    genero_pre.push_back = "Rhythmic Soul";
    genero_pre.push_back = "Rock";
    genero_pre.push_back = "Rock & Roll";
    genero_pre.push_back = "Salsa";
    genero_pre.push_back = "Samba";
    genero_pre.push_back = "Satire";
    genero_pre.push_back = "Shoegaze";
    genero_pre.push_back = "Showtunes";
    genero_pre.push_back = "Ska";
    genero_pre.push_back = "Slow Jam";
    genero_pre.push_back = "Slow Rock";
    genero_pre.push_back = "Sonata";
    genero_pre.push_back = "Soul";
    genero_pre.push_back = "Sound Clip";
    genero_pre.push_back = "Soundtrack";
    genero_pre.push_back = "Southern Rock";
    genero_pre.push_back = "Space";
    genero_pre.push_back = "Space Rock";
    genero_pre.push_back = "Speech";
    genero_pre.push_back = "Swing";
    genero_pre.push_back = "Symphonic Rock";
    genero_pre.push_back = "Symphony";
    genero_pre.push_back = "Synthpop";
    genero_pre.push_back = "Tango";
    genero_pre.push_back = "Techno";
    genero_pre.push_back = "Techno-Industrial";
    genero_pre.push_back = "Terror";
    genero_pre.push_back = "Thrash Metal";
    genero_pre.push_back = "Top 40";
    genero_pre.push_back = "Trailer";
    genero_pre.push_back = "Trance";
    genero_pre.push_back = "Tribal";
    genero_pre.push_back = "Trip-Hop";
    genero_pre.push_back = "Trop Rock";
    genero_pre.push_back = "Vocal";
    genero_pre.push_back = "World Music";

    initData.config[configName] = genero_pre;
}

function OnAddCommands(addCmdData) {
    var cmd = addCmdData.AddCommand();
    cmd.name = "Mp3TagFile";
    cmd.method = "OnMp3TagFile";
    cmd.desc = "";
    cmd.label = "Mp3 Tag File";
    cmd.template = "Mp3TagFile";
    cmd.hide = false;
    cmd.icon = "script";
}

function OnMp3TagFile(scriptCmdData) {
    var dlg = scriptCmdData.func.Dlg();
    dlg.title = "Mp3 Tag File - Directory Opus";
    dlg.template = 'Mp3TagFile';
    dlg.detach = true;
    dlg.Create

    var tab = scriptCmdData.func.sourcetab;
    var item = tab.selected_files(0);

    dlg.Control("archivo").value = item.name_stem;
    dlg.Control("titulo").value = item.metadata.audio.mp3title;
    dlg.Control("artista").value = item.metadata.audio.mp3artist;
    dlg.Control("album").value = item.metadata.audio.mp3album;
    dlg.Control("anio").value = item.metadata.audio.mp3year;
    dlg.Control("pista").value = item.metadata.audio.mp3track;
    dlg.Control("genero").label = item.metadata.audio.mp3genre;
    for (var i = 0; i < Script.config[configName].count; i++) {
        dlg.Control("genero").AddItem(Script.config[configName][i]);
    }
    dlg.Control("comentario").value = item.metadata.audio.mp3comment;
    dlg.Control("artista_album").value = item.metadata.audio.mp3albumartist;
    dlg.Control("compositor").value = item.metadata.audio.composers;
    dlg.Control("numero_disco").value = item.metadata.audio.mp3disc;

    if (item.metadata.audio.coverart > 0) {
        var tmpFile = DOpus.FSUtil().GetTempFile();
        tmpFile.Write(item.metadata.audio.coverart(0).data);
        tmpFile.Close();
        dlg.Control("caratula").label = Script.LoadImage(tmpFile);
    } else {
        dlg.Control("caratula").label = '';
    }

    dlg.Control("caratula").bg = "#FFFFFF";

    if (item.metadata.audio.coverart > 0) {
        var tmpFile = DOpus.FSUtil().GetTempFile();
        tmpFile.Write(item.metadata.audio.coverart(0).data);
        tmpFile.Close();
        var reso = item.metadata.audio.coverart(0);
        dlg.Control("resolucion").label = reso.width + " x " + reso.height + " x " + reso.depth + " (" + reso.size.fmt + ")";
    } else {
        dlg.Control("resolucion").label = '';
    }

    dlg.Control("resolucion").fg = "#000000";
    dlg.Control("resolucion").bg = "#FFFFFF";

    dlg.Show

    while (true) {
        msg = dlg.GetMsg();
        if (!msg.result) break;

        var sayGoodBye = false;

        var cmd = scriptCmdData.func.command;
        var coverart_usuario;

        if (msg.event == "click") {
            switch (msg.control) {

                case "btn_anadir_caratula":
                    coverart_usuario = dlg.open("Carátula");
                    dlg.Control("caratula").label = Script.LoadImage(coverart_usuario);
                    break;

                case "btn_eliminar_caratula":
                    dlg.Control("caratula").label = '';
                    dlg.Control("resolucion").label = '';
                    break;

                case "btn_eliminar_todo":
                    dlg.Control("titulo").value = '';
                    dlg.Control("artista").value = '';
                    dlg.Control("album").value = '';
                    dlg.Control("anio").value = '';
                    dlg.Control("pista").value = '';
                    dlg.Control("genero").label = '';
                    dlg.Control("comentario").value = '';
                    dlg.Control("artista_album").value = '';
                    dlg.Control("compositor").value = '';
                    dlg.Control("numero_disco").value = '';
                    dlg.Control("caratula").label = '';
                    dlg.Control("resolucion").label = '';
                    break;

                case "btn_guardar":
                    var cmdLine = 'SetAttr META' +
                        ' "title:' + dlg.Control('titulo').value + '"' +
                        ' "artist:' + dlg.Control('artista').value + '"' +
                        ' "album:' + dlg.Control('album').value + '"' +
                        ' "year:' + dlg.Control('anio').value + '"' +
                        ' "track:' + dlg.Control('pista').value + '"' +
                        ' "genre:' + dlg.Control('genero').value.name + '"' +
                        ' "comment:' + dlg.Control('comentario').value + '"' +
                        ' "albumartist:' + dlg.Control('artista_album').value + '"' +
                        ' "composers:' + dlg.Control('compositor').value + '"' +
                        ' "discnumber:' + dlg.Control('numero_disco').value + '"' +
                        ' "coverart:3:' + coverart_usuario + '"';

                    DOpus.Output(cmdLine);
                    cmd.RunCommand(cmdLine);
                    sayGoodBye = true;
                    break;

            }
        }
        if (sayGoodBye) break;
    }
}

==SCRIPT RESOURCES
<resources>
	<resource name="Mp3TagFile" type="dialog">
		<dialog fontsize="9" height="180" lang="esm" title="Mp3TagFile" width="332">
			<control halign="left" height="8" name="archivo_t" title="File:" type="static" valign="top" width="48" x="8" y="10" />
			<control halign="left" height="12" name="archivo" readonly="yes" type="edit" width="148" x="58" y="8" />
			<control halign="left" height="8" name="titulo_t" title="Title:" type="static" valign="top" width="48" x="8" y="26" />
			<control halign="left" height="12" name="titulo" type="edit" width="148" x="58" y="25" />
			<control halign="left" height="8" name="artista_t" title="Artist:" type="static" valign="top" width="48" x="8" y="43" />
			<control halign="left" height="12" name="artista" type="edit" width="148" x="58" y="42" />
			<control halign="left" height="8" name="album_t" title="Album:" type="static" valign="top" width="48" x="8" y="60" />
			<control halign="left" height="12" name="album" type="edit" width="148" x="58" y="59" />
			<control halign="left" height="8" name="anio_t" title="Year:" type="static" valign="top" width="48" x="8" y="78" />
			<control halign="center" height="12" name="anio" number="yes" type="edit" updown="yes" val_min="1" width="50" x="58" y="76" />
			<control halign="left" height="8" name="pista_t" title="Track:" type="static" valign="top" width="18" x="136" y="78" />
			<control halign="center" height="12" name="pista" number="yes" type="edit" updown="yes" val_min="1" width="30" x="157" y="76" />
			<control halign="left" height="8" name="genero_t" title="Genre:" type="static" valign="top" width="48" x="8" y="94" />
			<control edit="yes" height="40" name="genero" sort="yes" type="combo" width="148" x="58" y="93" />
			<control halign="left" height="8" name="comentario_t" title="Comment:" type="static" valign="top" width="48" x="8" y="111" />
			<control halign="left" height="12" name="comentario" type="edit" width="148" x="58" y="110" />
			<control halign="left" height="8" name="artista_album_t" title="Album artist:" type="static" valign="top" width="48" x="9" y="128" />
			<control halign="left" height="12" name="artista_album" type="edit" width="148" x="59" y="127" />
			<control halign="left" height="8" name="compositor_t" title="Composers:" type="static" valign="top" width="48" x="8" y="145" />
			<control halign="left" height="12" name="compositor" type="edit" width="148" x="58" y="144" />
			<control halign="left" height="8" name="numero_disco_t" title="Disc number:" type="static" valign="top" width="48" x="8" y="162" />
			<control halign="left" height="12" name="numero_disco" type="edit" updown="yes" val_min="1" width="148" x="58" y="161" />
			<control halign="center" height="8" name="resolucion" type="static" valign="top" width="100" x="218" y="95" />
			<control height="122" name="caratula_t" title="Cover" type="group" width="113" x="212" y="4" />
			<control halign="center" height="86" image="yes" name="caratula" type="static" valign="center" width="100" x="218" y="15" />
			<control height="14" name="btn_anadir_caratula" title="Add..." type="button" width="41" x="224" y="107" />
			<control height="14" name="btn_eliminar_caratula" title="Delete" type="button" width="41" x="272" y="107" />
			<control height="15" name="btn_eliminar_todo" title="Delete all" type="button" width="76" x="229" y="135" />
			<control default="yes" height="15" name="btn_guardar" title="Save" type="button" width="76" x="229" y="155" />
		</dialog>
	</resource>
</resources>
4 Likes

You sir... my hat is off. Touche

1 Like

Any chance of an English version of this?

Oi @juic3 , yes, I can do it, but I don't know whether to add a string with the English language to the original script (the same musical genres would be maintained), or make a completely new version in English, with the most common musical genres for you .

Could you tell me the most common genres for you, the ones you would like to exist in the "Genre" drop-down list? I could do it by searching on Goggle, but it will never be the same as someone's proposal.

Send me a message with everything you would like translated to English and I will do so... I would love an English version of this script, its what I've wanted for forever

Hello @travibe , thank you very much for your willingness to help me, but I have no problem doing the translation into English, they are few words and very easy to translate, what I would like you to help me with would be in the musical genres that you, the speakers English, they use more frequently, which with certainty, must be very different from those that I specified in my list of musical genres (Latin and Brazilian)

Help me with that, send me a list of the most common musical genres there, thank you very much!

How about this list?

/dopusdata\ConfigFiles\musicgenres.xml
1 Like

Perfect @lxp, I'll use that one, thank you very much!

Blues
Classic Rock
Country
Dance
Disco
Funk
Grunge
Hip-Hop
Jazz
Metal
New Age
Oldies
Other
Pop
R&B
Rap
Reggae
Rock
Techno
Industrial
Alternative
Ska
Death Metal
Pranks
Soundtrack
Euro-Techno
Ambient
Trip-Hop
Vocal
Jazz+Funk
Fusion
Trance
Classical
Instrumental
Acid
House
Game
Sound Clip
Gospel
Noise
AlternRock
Bass
Soul
Punk
Space
Meditative
Instrumental Pop
Instrumental Rock
Ethnic
Gothic
Darkwave
Techno-Industrial
Electronic
Pop-Folk
Eurodance
Dream
Southern Rock
Comedy
Cult
Gangsta
Top 40
Christian Rap
Pop/Funk
Jungle
Native American
Cabaret
New Wave
Psychadelic
Rave
Showtunes
Trailer
Lo-Fi
Tribal
Acid Punk
Acid Jazz
Polka
Retro
Musical
Rock & Roll
Hard Rock
Folk
Folk-Rock
National Folk
Swing
Fast Fusion
Bebob
Latin
Revival
Celtic
Bluegrass
Avantgarde
Gothic Rock
Progressive Rock
Psychedelic Rock
Symphonic Rock
Slow Rock
Big Band
Chorus
Easy Listening
Acoustic
Humour
Speech
Chanson
Opera
Chamber Music
Sonata
Symphony
Booty Bass
Primus
Porn Groove
Satire
Slow Jam
Club
Tango
Samba
Folklore
Ballad
Power Ballad
Rhythmic Soul
Freestyle
Duet
Punk Rock
Drum Solo
Acapella
Euro-House
Dance Hall

I got this from my Tag&Rename program... I couldn't specifically pick out the most popular because that would be different for everyone.

1 Like

Thank you very much for your list, but I just published the version of the script in English with the list suggested by @lxp, Opus' own, try the script and tell me if it is okay, thank you very much!

Did you see it? Our prayers have already been answered:

Added scripting DOpus.MusicGenres() method to access the list of defined music genres

You can now maintain all your genres within Opus and use them outside the metadata panel.

To feed them to your dialog, use

for (var e = new Enumerator(DOpus.MusicGenres()); !e.atEnd(); e.moveNext()) {
    dlg.Control("genero").AddItem(e.item());
}
3 Likes

It makes me very happy to see that Opus is becoming more perfect every day, that things are becoming more simplified every day.

I will try to implement this method in the script, thank you very much!

2 Likes

Thank you so much for The script and One more thanks for @lxp for his great help for build the script.

2 Likes

@travibe and @khalidhosain I have updated the script, thanks to the help of @Wken, now is possible to edit the list of musical genres, just read the description of the script, enjoy it.

1 Like

Absolutely fantastic script it's becoming one of my go-to favorites! Is the best for on the spot quick fixing any files that have random erroneous entries or whatnot instead of having to load a whole program and have it scan the folder and all that nonsense. I would place this in the top five best scripts of all time (seriously!}!

Just like the post one or two above this one stated, watching DOpus grow and evolve into the best file manager while also playing a very tiny part in it ourselves (i.e. the community) is a very very cool thing indeed. It's little fixes like this that the community contributes which adds to DO's already massive list of capabilities that set it so far ahead of all the other competitors. Go team! Lol

2 Likes

I am very happy that you liked this script, I did it with a lot of love, thinking of something simple and quick to use, I assigned the F4 key to the button and I don't even need to press the button.

Now I'm thinking about inserting two small buttons to jump to the previous file and the next in case it is necessary to edit other files. I'll let you know when it's ready in case you're interested in this new version.

I forgot to tell you about Opus, for me it is the best file explorer in the world, for three simple reasons.

  1. Versatility (high number of options and functionalities).
  2. Very high level of customization (practically everything can be customized).
  3. Powerful technical assistance (that interaction with the forum community, which is practically instantaneous, is difficult to see on other sites).
1 Like

Thank you so much for this nice Script. I have face a small problem.
When I Select multiple files with multiple track no. and multiple Title. then update only one field Album Name. when I click on save button, it's change all files track no. in same number and all my Title name is same name. but when I select multiple files and I didn't change or input any value in the track no. or Title: field then I want my track no and Title should remain as it was.

2nd Issue. I need 2 more fields here for update or input copyright and publisher columns information.

@khalidhosain The script is designed to work with a single file, that's how I specified it in the description "This script allows you to edit the metadata of a single Mp3 file". If you select multiple files, the changes you make will be applied to all files.

To edit several files at the same time, respecting the different values of each file, I recommend using Steve's script (link), which I also refer to in the script description.

Regarding the "copyright" field (item.metadata.audio.copyright), I did not include it because the intention of the script is really a quick and simple way to edit the most important metadata, I did not want a huge window with a lot of visual content.

In terms of music, I think the "Composers" and "Album artist" (Music producer) fields are most used, however, these days, when I can, I will make a version for you with those fields added.

The built-in metadata editor also handles multiple files.