use os.walk to enumerate all files under a directory, os.path.splitext to get a file's extension.