代码:
import os
import sysdef showsmallfiles(dir): v=os.listdir(dir) for i in v: d="%s/%s"% (dir,i) if os.path.isdir(d): showsmallfiles(d) else: if os.path.getsize(d) < int(sys.argv[2]): logger(d)#logfiledef logger(text): f=open('d:/python/log.txt','a') f.write(text+'\r\n') f.close()if len(sys.argv)<3: print('arguments is invalid') sys.exit()showsmallfiles(sys.argv[1])调用方式:
python listsmallfile.py d:/python 1000
posted on 2011-08-10 11:51 阅读( ...) 评论( ...)