[Level 2] Recursive directory list
#!/bin/env python import os, sys wholeFileList = [] baseDir = sys.argv[1] for parentDir, childDirList, fileList in os.walk(baseDir): for file in fileList: wholeFileList.append(os.path.join(parentDir,file)) for file in wholeFileList: print file
# ./t.py /tmp/d /tmp/d/1.txt /tmp/d/2/6.txt /tmp/d/2/3/a.txt /tmp/d/2/4/b.txt /tmp/d/2/5/c.txtWish this helps. regards, Stanley Huang
Comments
Post a Comment