Created
August 23, 2019 22:51
-
-
Save kowalcj0/8455ea4cf19f9a50da8b0ce59cd13cd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import shutil | |
def what_is_inside(types) -> str: | |
result = "" | |
if "mp3" in types and "flac" in types: | |
result = "both" | |
if "mp3" in types and not "flac" in types: | |
result = "mp3" | |
if not "mp3" in types and "flac" in types: | |
result = "flac" | |
return result | |
res = [] | |
for path in os.listdir("./"): | |
# skip files in parent dir | |
if os.path.isfile(path): | |
continue | |
types = [] | |
for root, dirs, paths in os.walk(path): | |
types += [f.split(".")[-1].lower() for f in paths] | |
types = set(types) | |
dir_type = what_is_inside(types) | |
print(f"{dir_type} -> {path} -> {types}") | |
if dir_type == "flac": | |
try: | |
shutil.move(path, "../FLAC") | |
except shutil.Error as ex: | |
print(ex) | |
if dir_type == "mp3": | |
try: | |
shutil.move(path, "../mp3") | |
except shutil.Error as ex: | |
print(ex) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment