Created
November 29, 2021 15:11
-
-
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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