[Python] Using python & eyeD3 to null some tag fields

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I have 1,350 1970s MP3s that I want to remove the album name and track numbers from the audio tag (meta) data using eyeD3. From examples on the Internet, I was able to cobble the following.

    When run, the error says - AttributeError: 'NoneType' object has no attribute 'album'.

    Internet examples suggest to use audiofile.tag.album and audiofile.tag.track_num. The documentation is not clear how to use but has album and track as fields in the (meta) data.

    Python is V3.12 running on Windows 10 using MICROSOFT VISUAL STUDIO CODE

    Please help with suggestions to a successful program.

    import os
    import eyed3

    # Assign directory
    directory = r"C:\Users\bill\Temp"
    Null = ""


    # Iterate over files in directory
    for name in os.listdir(directory):
    # Open file
    with open(os.path.join(directory, name)) as f:
    print(f"Content of '{name}'")

    audiofile = eyed3.load(directory + '\\' + str(name))
    print(audiofile.tag)
    # Modify the metadata.
    #'''
    audiofile.tag.album = u""
    audiofile.tag.track_num = u""
    #Save changes.
    audiofile.tag.save()
    #'''
    ```

    Continue reading...

Compartilhe esta Página