Skip to content

Instantly share code, notes, and snippets.

@kowalcj0
Created August 23, 2019 22:51
Show Gist options
  • Save kowalcj0/8455ea4cf19f9a50da8b0ce59cd13cd2 to your computer and use it in GitHub Desktop.
Save kowalcj0/8455ea4cf19f9a50da8b0ce59cd13cd2 to your computer and use it in GitHub Desktop.
#!/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