Skip to content

Instantly share code, notes, and snippets.

@shavidzet
Last active August 31, 2018 13:21
Show Gist options
  • Save shavidzet/4db7dd668c6c71a06e0c64da27e6d248 to your computer and use it in GitHub Desktop.
Save shavidzet/4db7dd668c6c71a06e0c64da27e6d248 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import os, fnmatch
def findReplace(directory, find, replace, filePattern):
for path, dirs, files in os.walk(os.path.abspath(directory)):
for filename in fnmatch.filter(files, filePattern):
filepath = os.path.join(path, filename)
with open(filepath) as f:
s = f.read()
s = s.replace(find, replace)
with open(filepath, "w") as f:
f.write(s)
findReplace("./", "‘", "'", "code.js")
findReplace("./", "’", "'", "code.js")
git clone https://gist.github.com/4db7dd668c6c71a06e0c64da27e6d248.git ./chars-quick-fix
python ./chars-quick-fix/medium-js-fix.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment