删除目录中没有元数据(标题、艺术家等)的特定 mp3 文件?

Delete particular mp3 files in a directory that has no metadata(Title,artist etc)?

我想删除目录中没有元数据(标题、艺术家等)的特定 mp3 文件。我尝试对文件进行排序,然后手动将其删除,但由于文件数量巨大(~30K),所以没有用。是否有任何 python 脚本来完成此任务?

此示例脚本尚未完成,但我希望它能为您提供良好的起点。

import os
import glob
from mutagen.easyid3 import EasyID3

mp3_files_list = glob.glob(path/to/your/mp3-files-folder/*.mp3) # example path /home/user/Downloads/mp3/*.mp3

for mp3_file in mp3_files_list:
    audio = EasyID3(mp3_file)
    if not audio['title']: # if title tag is empty
        os.remove(mp3_file)
    if not audio['artist']:
        os.remove(mp3_file)
    # etc tags check

Mutagen 模块文档:https://mutagen.readthedocs.io/en/latest/