#!/usr/bin/python # Copyright 2020 (c) Anna Schumaker # # Use Mutagen to generate a list of tracks missing a specific tag for # all music files in the requested directory import mutagen import os import pathlib import sys if len(sys.argv) != 3 or not os.path.isdir(sys.argv[2]): print(f"Usage: {sys.argv[0]} TAG DIRECTORY") sys.exit(1) print() print(f"Reading directory {sys.argv[2]}:") files = [ ] for entry in pathlib.Path(sys.argv[2]).rglob("*"): if os.path.isfile(entry): files += [ entry ] print(f" Found {len(files)} files") missing = [ ] read = 0 skip = 0 for f in files: try: keys = set(mutagen.File(f).keys()) if sys.argv[1] not in keys: missing += [ f ] read += 1 except Exception as e: #print(e) skip += 1 print(f" Read {read} files, skipped {skip}") print(f" There are {len(missing)} files missing the \"{sys.argv[1]}\" tag:") for f in missing: print(f" {f}") print()