Skip to content

Instantly share code, notes, and snippets.

@vinloo
Created November 29, 2021 15:11
Show Gist options
  • Select an option

  • Save vinloo/a2360b5a6319ba0e7c702911248e880b to your computer and use it in GitHub Desktop.

Select an option

Save vinloo/a2360b5a6319ba0e7c702911248e880b to your computer and use it in GitHub Desktop.
Clear all metadata from mp3 files (in folder + all subfolders) except for the title and artist
# This program clears all metadata from mp3 files except for the title and artist
from pathlib import Path
from mutagen.easyid3 import EasyID3
INPUT_DIR = Path.cwd() / "Music"
count = 1
for file in list(INPUT_DIR.rglob("*.mp3*")):
audio = EasyID3(file)
for key in audio:
if key != 'title' and key != 'artist':
try:
audio[key] = ''
except (IndexError, ValueError) as e:
print(f'Ran into error when cleaning {audio["title"]}')
audio.save()
count += 1
print(f'Done cleaning {count} songs!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment