Skip to content

Instantly share code, notes, and snippets.

@gubiithefish
Last active August 22, 2018 11:37
Show Gist options
  • Save gubiithefish/b8b6e4298585efc43b66268dff8f2d22 to your computer and use it in GitHub Desktop.
Save gubiithefish/b8b6e4298585efc43b66268dff8f2d22 to your computer and use it in GitHub Desktop.
A small code for escaped html files which unescapes and moves them to another folder.
import html
import io
import os
from_dir_path = 'C:\\Users\\gubii\\Desktop\\testmappe\\txt\\Michael\\' #AlleFilerSkalLiggeHer
to_dir_path = 'C:\\Users\\gubii\\Desktop\\testmappe\\txt\\Michael2\\'
for files in os.listdir(from_dir_path):
file = open(from_dir_path + files, encoding="utf8")
text = file.readlines()
if files not in os.listdir(to_dir_path):
new_file = io.open(to_dir_path + files, "w", encoding="utf-8")
for lines in range(len(text)):
new_file.writelines(html.unescape(text[lines]))
new_file.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment