代码:
import os
import sys
def 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)
#logfile
def 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