-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmusic_bat_creator.py
More file actions
33 lines (29 loc) · 971 Bytes
/
music_bat_creator.py
File metadata and controls
33 lines (29 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import sys
import yaml
dirpath = os.path.dirname(__file__)
os.chdir(dirpath)
arg = ""
if len(sys.argv) > 1:
arg = sys.argv[1]
musiclist = None
if arg != "":
with open(arg, 'r', encoding='utf-8') as music:
musiclist = yaml.load(music)
File = open("music categorizer.bat", "w")
current_category = ""
if musiclist:
input("Making a .bat file to recategorize music based on .yaml file. Press ENTER to begin.")
File.write('CD base\n')
File.write('CD sounds\n')
File.write('CD music\n')
for item in musiclist:
if 'category' not in item:
continue
cat = item['category'].strip('=')
File.write('IF NOT EXIST "{}" MKDIR "{}"\n'.format(cat, cat))
for song in item['songs']:
File.write('MOVE "{}" "{}"\n'.format(song['name'], os.path.join(cat, song['name'])))
input("Done! Press ENTER to exit.")
else:
input("You must drag a music.yaml on top of this script to begin.")