import osimport os.pathimport timeimport shutildef my_cmp(E1, E2): return -cmp(E1[1], E2[1])L={}k={}count=0rootdir = "/home/xiayu/.mozilla/firefox/06ze02mw.default/Cache"desdir="/tmp/friend/"for parent, dirnames, filenames in os.walk(rootdir):#case 1:# for dirname in dirnames:# print "parent is:" + parent# print "dirname is:" + dirname#case 2 for filename in filenames:# print "filename with full path " + os.path.join(parent, filename) + " size %d"% os.path.getsize(os.path.join(parent, filename)) # L[os.path.join(parent, filename)]=os.path.getsize(os.path.join(parent, filename)) name=os.path.join(parent, filename) if(os.path.getsize(name)/1024/1024>0): L[name]=os.path.getctime(name) count=count+1 print name print "count :",countcount=0k=sorted(L.iteritems(), key=lambda L:L[1],reverse = False)for i in range(len(k)): print k[i][0],"\t",k[i][1],"\t",os.path.getsize(k[i][0])/1024/1024 name='%d'% (i+1) name=desdir+name print name shutil.copyfile(k[i][0],name)