Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- debug = False
- format = 1 #or 2
- def main():
- extlist = (".mp3",".m4a",".wav", ".ogg")
- if debug:
- index = [('/media/user/D/Commmon/Music/ZZ Top', [], ['Sharp Dressed Man.mp3', 'FakeSong - ZZ Top.ogg', '015 - Yeetus.mp3'])]
- else:
- index = list(os.walk("/media/user/D/Common/Music/"))# Grab list of artists and folders
- file = open("songslist.txt", "w")
- for entry in index:
- artist = entry[0].split("/")[-1]
- out = []
- for i in entry[2]: #for each filename in artist folder
- if i.endswith(extlist):
- name = i
- tmp = i.split(" -!- ")[0].split(".")
- if len(tmp) > 1:tmp.pop()
- name = "".join(tmp)
- try:
- isdash = name.index(" - ")
- except ValueError:
- isdash = -1
- if isdash != -1:
- name = name.split(" - ")
- if artist.lower() in name[0].lower(): choice = 1
- elif artist.lower() in name[1].lower(): choice = 0
- else: choice = -1
- if choice == -1: out.append(" - ".join(name))
- if not choice == -1: out.append(name[choice])
- else:
- out.append(name)
- newlinetab = "\n "
- if len(out) > 0:
- print(f"{artist}\n {newlinetab.join(out)}")
- file.write(f" -!- {artist}\n".join(out))
- file.close()
- if __name__ == "__main__":
- main()
- exit()
- # file = open("songslist.txt", "w")
- # for name in songnames:
- # file.write(f"\"{name}\" -!- {artist}")
- # file.close()
Advertisement
Comments
-
- I slapped this together one day to try and make a list of the songs I have and deal with how the filenames and folder structure were formatted.
- I really need to go through and normalize all of the filenames. I might just use Den4b Renamer to do so (using wine, since I'm on Linux)
Add Comment
Please, Sign In to add comment
Advertisement