Я решил это сам, используя маленький скрипт на Python и хромой. Вот скрипт Python:
import os
import sys
from os.path import join
from subprocess import call
class Converter:
def convert(self, in_file_name, out_file_name):
if os.path.isfile(out_file_name):
return
out_dir = os.path.dirname(out_file_name)
if not os.path.isdir(out_dir):
print '!!!!!!!!!!!!!'
print 'creating ' + out_dir
print '!!!!!!!!!!!!!'
os.makedirs(out_dir)
print 'now converting ' + in_file_name + ' to ' + out_file_name
call(['lame', '-h', in_file_name, out_file_name])
def _is_supported_audio_format(self, format):
return format.lower() in ['mp3', 'aac']
def copyAndConvertAll(self, in_root, out_root):
originalRoot = None
for root, dirs, files in os.walk(in_root):
# to ensure we get the correct path, not just something relative
if originalRoot == None:
originalRoot = root
for file in files:
if self._is_supported_audio_format(file[-3:]):
targetFileName = join(out_root, join(root, file)[len(originalRoot):])
self.convert(join(root, file), targetFileName)
if __name__ == '__main__':
converter = Converter()
converter.copyAndConvertAll(sys.argv[1], sys.argv[2])
просто вызовите его через python convert.py [source dir] [target dir], например, python convert.py /Users /MyUser /Music /Users /MyUser /ConvertedMusic