#!/usr/bin/python3 from glob import glob import subprocess import os for f in glob('gongs/*/*.mp3'): t = f.replace('gongs/', 'gongs_wav/').replace('.mp3', '.wav') print(f, t) folder = os.path.dirname(t) if not os.path.exists(folder): os.makedirs(folder) subprocess.call(['ffmpeg', '-i', f, t])