-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxiaolei_script2.py
More file actions
29 lines (26 loc) · 925 Bytes
/
Copy pathxiaolei_script2.py
File metadata and controls
29 lines (26 loc) · 925 Bytes
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
import os
#set working directory
os.chdir(r'C:\Users\xiaol\OneDrive\Documents\PyGiScraping\files')
#list of files in the directory
filelist = os.listdir(os.getcwd())
print(os.listdir(os.getcwd()))
#prompt user for input
input_text = input("Search for the input phrase (case-sensitive): ")
source_bank = [input_text]
#iterate through each file to check for input phrase
for i in filelist:
print(i)
try:
#open current file and duplicated_slides where all the file names will be stored.
with open('duplicated_slides.txt', 'a') as d, open(i, encoding ='utf8') as f:
f = f.read()
for slide in source_bank:
print(slide in f)
if slide in f:
print(i)
d.write(i)
d.write("\n")
print("yay")
d.close()
except OSError as error:
print('error %s', error)