I’ve been moving a bunch of my brothers music out of iTunes for him so he can use it with portable players besides iPod. Unfortunately he encoded a lot of his cd’s in .m4a format. I found a decent utility for converting to mp3 (and other formats) http://www.bonkenc.org/
Unfortunately when you point Bonk at a directory full of m4a’s it crashes on certain files for some reason (encoding issues probably.) After the crash you need to setup all of your settings and add the files again, which is really time consuming and annoying.
To make this easier I whipped up a short python script that calls Bonk for you on each file, if it runs into a bad file it will rename the file for you so you don’t try to process it again.
Here’s the python code:
import os import pprint import subprocess curDir = os.getcwd() # The current directory. This should contain your .m4a files pathToBonk = "C:\\Program Files\\BonkEnc\\becmd.exe" #Where the becmd.exe file lives problemFiles = [] #A list of files that failed conversion # for item in os.listdir(curDir): if item.upper().endswith('.M4A'): fullPath = os.path.join(curDir,item) cmd = '"%s" -e LAME -d "%s" "%s"' #The command to convert a single file cmd = cmd % (pathToBonk, curDir, fullPath) val = subprocess.call(cmd) if val == 0: #Successfull conversion, delete the original os.remove(fullPath) else: problemFiles.append(fullPath) print 'Problem converting %s' % item os.rename(fullPath, fullPath + ".BAD") print 'These files had problems converting and have been renamed with .BAD extensions:' pprint.pprint(problemFiles)
NOTES: This will delete the .m4a file after converting it. If you want to keep your old files for some reason make sure to run this on a copy of your files. IE in a different directory.