Multiple genres

Main discussion forum
Post Reply
struwwelpeter
Newbie
Newbie
Posts: 4
Joined: Mon Jan 16, 2017 3:32 pm

Multiple genres

Post by struwwelpeter »

Happy new year!

I'm a new user to Godfather having discovered it is (I think) the only utility out there which can identify files which have more than one instance of the same field.

I have a number of files within my library which have at least two instances of the same field (mostly GENRE - over the last fifteen years I've gone through a number of library programmes and unfortunately not all were standards compliant) and I'd like to know the best way to strip out the second instance.
Clipboard01.jpg
Clipboard01.jpg (75.89 KiB) Viewed 4120 times
Is this something which can be automated on a whole-library basis or a per-album basis?

Thank you very much for any help.

Cheers,
Peter.

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: Multiple genres

Post by jtclipper »

Hello,
a script could be used for that, but first please send me a few of your files files as samples, so I can have a look.

struwwelpeter
Newbie
Newbie
Posts: 4
Joined: Mon Jan 16, 2017 3:32 pm

Re: Multiple genres

Post by struwwelpeter »

Hi Dimitris,

Here are three files which exhibit the multiple genre problem: https://drive.google.com/drive/folders/ ... sp=sharing

1-01.m4a and 1-05.m4a should both have genre 'Classical' and 1-16.m4a should be 'Choral'.
I have a fixed set of genres that I use, if that helps, and my library is around 350,000 files.

Very many thanks for your swift response,
Peter.

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: Multiple genres

Post by jtclipper »

Mp4 files have two 'official' ways to store genre data, those are fields (in the mp4 container format they are called atoms) named gnre or ©gen.
The first one is basically a number (ordinal position in a list much like ID3v1 tags) the second one is a text string and much more flexible.

Your mp4 files have additional genre data stored as user fields and also the standard genre atom 'gnre' (the one you can see in the first page of the 'full tag edit dialog').
TGF uses the '©gen' atom upon saving.

I can write a simple script to get rid of the additional 'GENRE' user fields and just keep the original/official genre atom, and it seems that in your case that should do the trick.
But first do the following to be 100% sure that other software you use are compatible with the '©gen' atom:
use the full tag edit dialog to remove the 'GENRE' user fields and update a few files, after that use your player/music management software and make sure it reads the files correctly.
If everything is in good order this process can be automated.

struwwelpeter
Newbie
Newbie
Posts: 4
Joined: Mon Jan 16, 2017 3:32 pm

Re: Multiple genres

Post by struwwelpeter »

I've done some checking and can confirm that my players and library software are all happy with the '©gen' atoms.

Thank you very much! :)

User avatar
jtclipper
Administrator
Administrator
Posts: 768
Joined: Tue Aug 10, 2010 12:04 pm

Re: Multiple genres

Post by jtclipper »

This is the script to automate the job, i tested on your files and it works but please do a test run yourself on a few of your files before going full scale.

Code: Select all

program genre_fix;
var
 i: integer;
 bUpdated: boolean;
begin

  if not tg_Init then exit; // no rows get out
  repeat

    bUpdated := false;
    tg_LoadFile;

    for i := 0 to gTag.ExtraFieldsCount - 1 do begin
        if UpperCase( gTag.ExtraFieldID( i ) ) = 'GENRE' then begin //check for genre user field and set to blank
           gTag.ExtraFieldValueSet( i, '' );
           bUpdated := true;
        end;
    end;

    if bUpdated then begin
       if gTag.SaveToFile( 0, false ) then begin  //save to file
          tg_SetResult( 'OK' );
       end else begin
          tg_SetResult( 'Error saving!' );
       end;
    end else begin
       tg_SetResult( 'N/A' );
    end;

  until not tg_Skip;

end.

struwwelpeter
Newbie
Newbie
Posts: 4
Joined: Mon Jan 16, 2017 3:32 pm

Re: Multiple genres

Post by struwwelpeter »

It worked beautifully - thank you so much for your help, Dimitris! :D

Very much appreciated,
Peter.

Post Reply