From 0634c8b56e9309576f85de127779bee4fb3bdf77 Mon Sep 17 00:00:00 2001 From: kass Date: Sat, 6 May 2023 21:43:20 -0400 Subject: [PATCH] First commit --- README.md | 3 +++ main.py | 29 +++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 33 insertions(+) create mode 100644 README.md create mode 100644 main.py create mode 100644 requirements.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..6b47669 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Music Organizer +Simple script to move my downloaded music into folders based on the artist and album name \ +Pairs well with [spotdl](https://github.com/spotDL/spotify-downloader) \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..d9cdf6c --- /dev/null +++ b/main.py @@ -0,0 +1,29 @@ +import os, eyed3, re, shutil + +path = input('Enter to full path to the directory containing you files: ') +dest = input('Enter the full path to the destination: ') + +with os.scandir(path) as dir_entries: + for entry in dir_entries: + for entry in dir_entries: + if bool(re.search(r'.*\.mp3', entry.name)) is True: + file = eyed3.load(entry) + artist = file.tag.artist + artist = re.sub(r'(\/)|(\\)|(\:)|(\*)|(\?)|(\")|(\<)|(\>)|(\|)|(\ )$', ' ', artist) + album = file.tag.album + album = re.sub(r'(\/)|(\\)|(\:)|(\*)|(\?)|(\")|(\<)|(\>)|(\|)|(\ )$', ' ', album) + + artistIsExist = os.path.exists(f'{dest}\\{artist}') + if not artistIsExist: + os.makedirs(f'{dest}\\{artist}') + albumIsExist = os.path.exists(f'{dest}\\{artist}\\{album}') + if not albumIsExist: + os.makedirs(f'{dest}\\{artist}\\{album}') + song = entry.name + song = re.sub(r'(\/)|(\\)|(\:)|(\*)|(\?)|(\")|(\<)|(\>)|(\-)|(\|)|(\ )$', '', song) + song = re.sub(r'\ +', ' ', song) + try: + shutil.copy(entry.path, str(f'{dest}\\{artist}\\{album}\{song}')) + except: + print(song) + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..76fa453 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +eyeD3 == 0.9.7 \ No newline at end of file