import os, dircache, sys, string pathToConvertor="D:\\Archive\\Multimedia\\ffmpeg2theora-0.19.exe"; def convert(filePath, args="", deleteOriginal=False): size=os.stat(filePath)[6] #file size if not args=="": toExec=pathToConvertor+" "+args+" "+filePath else: toExec=pathToConvertor+" "+filePath os.system(toExec) newPath=string.replace(filePath, ".AVI", ".OGG") sizeDelta=size-os.stat(newPath)[6] if deleteOriginal==True: os.remove(filePath) return sizeDelta def traverse(rootdir): filelist=[] a=dircache.listdir(rootdir) totalSizeDelta=0 for root, dir, files in os.walk(rootdir): for object in files: capitalized=object.upper() if capitalized.endswith(".AVI"): fullPath=os.path.join(root, object) totalSizeDelta+=convert(fullPath)#, "-v 10", False) filelist.append(fullPath) return totalSizeDelta, filelist savedSpace, convertedFiles=traverse("D:\\Stuff\\Photos\\_dig\\Netherlands") print "You saved %i bytes" % savedSpace #if you haven't deleted originals, you can still do that #the list is in convertedFiles