I want to walk a folder structor and group all the files by extention.
Here is the code I put together is there a better way of doing this? <code> import os folderKey = "Folders" dicExt = {} tDicKey = [] tDicKey.append(folderKey) dicExt[folderKey] = [] walkPath = r"\\zek\C$\AST" for d in os.walk(walkPath): (dirpath, dirnames, filenames) = d dicExt[folderKey].append(dirpath) for fname in filenames: fs = os.path.splitext(fname) if dicExt.has_key(fs[-1]): dicExt[fs[-1]].append(os.path.join(dirpath,fname)) else: dicExt[fs[-1]] = [] dicExt[fs[-1]].append(fname) tDicKey.append(fs[-1]) for k in tDicKey: print k +" "+ str(len(dicExt[k])) </code> Right now it is just prints out the counts. Thanks Erin -- http://mail.python.org/mailman/listinfo/python-list