Skip to content

Commit cefabcb

Browse files
committed
Warn the user if more than 2 different artists are found.
1 parent 1127060 commit cefabcb

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

python2.7/music-organizer.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,31 @@ def toNeat(s):
1616
sys.exit(-42)
1717
return s
1818

19+
artists = set()
20+
valid = {"yes":True, "y":True, "no":False, "n":False}
21+
for dirname, dirnames, filenames in os.walk('.'):
22+
# Make sure there aren't a lot of different artists
23+
# in case this was called from the wrong directory.
24+
for filename in filenames:
25+
try:
26+
audio = EasyID3(os.path.join(dirname, filename))
27+
artist = audio['artist'][0].decode()
28+
artists.add(artist)
29+
except:
30+
pass
31+
32+
if len(artists) > 2:
33+
while True:
34+
print("Warning: More than 2 artists found.")
35+
print("This will move all songs to the current directory.")
36+
print("Continue? yes/no")
37+
choice = raw_input().lower()
38+
if choice in valid:
39+
if valid[choice]: break
40+
else:
41+
print("Exiting.")
42+
sys.exit(-1)
43+
1944
delete_dirs = []
2045
for dirname, dirnames, filenames in os.walk('.'):
2146
# Move all the files to the root directory.

0 commit comments

Comments
 (0)