import subprocess
import os

# Iterate over files in directory
for folder in os.listdir("./"):
    if os.path.isdir(folder):
        for file in os.listdir(folder):
            choplength = 0
            if file.endswith(".flac"):
                choplength = 4
                newfilename = folder+"/"+os.fsdecode(file)
                subprocess.run(["ffmpeg", "-i", newfilename, "-ab", "320k", newfilename[:-4] + "mp3"])
                subprocess.run(["ls", "-a"])
                print("converted " + folder + "/" + file)
