Amazing-Python-Scripts
20 строк · 824.0 Байт
1import os2from os.path import join3for (dirname, dirs, files) in os.walk('.'):4for filename in files:5if filename.endswith('.txt'):6thefile = os.path.join(dirname, filename)7size = os.path.getsize(thefile)8if size == 2578 or size == 2565:9print 'T-Mobile:', thefile10# os.remove(thefile) Add this when you are sure to delete the file11continue12fhand = open(thefile, 'r')13lines = list()14for line in fhand:15lines.append(line)16fhand.close()17if len(lines) == 3 and lines[2].startswith('Sent from my iPhone'):18print 'iPhone:', thefile19# os.remove(thefile) Add this when you are sure to delete the file20continue21