from pathlib import Path files = [ Path(r"C:\Users\jan\Downloads\sdr-wideband-suite\web\app.js"), Path(r"C:\Users\jan\Downloads\sdr-wideband-suite\web\index.html"), Path(r"C:\Users\jan\Downloads\sdr-wideband-suite\web\style.css"), ] repl = { '·': '·', '…': '…', '—': '—', '–': '–', '→': '→', 'â†\x90': '←', 'â– ': '■', 'â– ': '■', '×': '×', 'â•\x90': '═', '─': '─', } for p in files: s = p.read_text(encoding='utf-8') o = s for a, b in repl.items(): s = s.replace(a, b) if s != o: p.write_text(s, encoding='utf-8', newline='')