From 68a32857b5160757b4956cc772481c76331d9e33 Mon Sep 17 00:00:00 2001 From: Dilan Gilluly Date: Sun, 8 Feb 2026 23:11:12 -0500 Subject: [PATCH] initial commit --- main.py | 29 +++++++++++++++++++++++++++++ requirements.txt | 1 + 2 files changed, 30 insertions(+) create mode 100644 main.py create mode 100644 requirements.txt diff --git a/main.py b/main.py new file mode 100644 index 0000000..0fead7d --- /dev/null +++ b/main.py @@ -0,0 +1,29 @@ +from pathlib import Path +from tinytag import TinyTag + +select_extensions = (".mp3", ".m4a") + +def main(): + current_path = Path("./") + music_files = [] + + for e in select_extensions: + music_files.extend(current_path.rglob(f"*{e}")) + + print(f"Discovered {len(music_files)} music files.") + yn = input("Do you want to sort them? (y or n) ") + + if yn == "y": + for file in music_files: + tags = TinyTag.get(file) + current_file = Path(file) + new_path = current_path / f"{tags.albumartist or tags.artist}" / f"{tags.album}" / current_file.name + new_path.parent.mkdir(parents=True, exist_ok=True) + current_file.rename(new_path) + print(f"Moved {current_file} to {new_path}.") + print(f"Succeeded in sorting {len(music_files)} music files.") + else: + quit(0) + +if __name__ == "__main__": + main() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4a5ca4f --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +tinytag