-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppSearch.py
72 lines (64 loc) · 2.37 KB
/
ppSearch.py
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
#Python 3.x
#Jonathan Obenland 10/24/2019
#A simply program to search a directory of power points
from pptx import Presentation
from datetime import datetime
import os
def main():
print('')
print('A simple power point search tool by Jonathan')
print('')
while (True):
hitCount = 0
keyword = input("Enter word to search for (case sensitive): ")
path = input("Enter path of power point files: ")
#result=[]
os.chdir(path)
startTime = datetime.now()
hitList = []
print('')
print('Script started at',startTime)
print('')
print('-------------')
print('')
for filename in os.listdir():
#startTime = datetime.now()
result=[]
if not filename.endswith('.pptx'):
continue
presFile = Presentation(filename)
slides = presFile.slides
print("Searching", filename)
print(' ')
for slide in presFile.slides:
slideNum = str(slides.index(slide)+1)
for attribute in slide.shapes:
if not attribute.has_text_frame:
continue
for textFrame in attribute.text_frame.paragraphs:
for run in textFrame.runs:
if keyword in run.text:
words = slideNum,run.text
result.append(words)
if filename not in hitList:
hitList.append(filename)
hitCount+=1
else:
continue
if result == []:
print("No Hits for",keyword)
print("Check case or try agian")
print('')
elif result != []:
print(result)
print('')
timerCalc=datetime.now() - startTime
print('-------------')
print('')
print("Proccess finished in",timerCalc,"with",hitCount,"hits in",len(hitList),"powerpoints")
print("hits were found in",hitList)
print('')
print('-------------')
print('')
if __name__ == '__main__':
main()