1import sys
2import glob
3import os.path
4
5list_of_files = glob.glob('/Users/Emily/Topics/*.txt') #500 files
6
7for file_name in list_of_files:
8 print(file_name)
9
10 # This needs to be done *inside the loop*
11 f= open(file_name, 'r')
12 lst = []
13 for line in f:
14 line.strip()
15 line = line.replace("\n" ,'')
16 line = line.replace("//" , '')
17 lst.append(line)
18 f.close()
19
20 f=open(os.path.join('/Users/Emily/UpdatedTopics',
21 os.path.basename(file_name)) , 'w')
22
23 for line in lst:
24 f.write(line)
25 f.close()