I am using the following Python - Beautifulsoup code to remove html elements from a text file:
from bs4 import BeautifulSoup
with open("textFileWithHtml.txt") as markup:
soup = BeautifulSoup(markup.read())
with open("strip_textFileWithHtml.txt", "w") as f:
f.write(soup.get_text().encode('utf-8'))
The question I have is how can I apply this code to every text file in a folder(directory), and for each text file produce a new text file which is processed and where the html elements etc. are removed, without having to call the function for each and every text file?