Skip to content

Instantly share code, notes, and snippets.

@QQism
Last active December 16, 2015 07:48
Show Gist options
  • Save QQism/5400978 to your computer and use it in GitHub Desktop.
Save QQism/5400978 to your computer and use it in GitHub Desktop.
Convert all wav files in a path to mp3, using lame. Usage: ./convert_wav_to_mp3 my/wav/folder
#!/usr/bin/env python
# require lame http://lame.sourceforge.net
import sys
import os
import re
import subprocess
path = sys.argv[1:][0]
wav_files = []
for dirname, dirnames, filenames in os.walk(path):
wav_files += [os.path.join(dirname, filename) for filename in filenames if re.match(r'.*\.wav', filename)]
for filename in wav_files:
command = 'lame --preset insane "' + filename + '"'
subprocess.call(command, shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment