Skip to content

Instantly share code, notes, and snippets.

@nicholasodonnell
Last active July 25, 2017 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicholasodonnell/1218544f96c52e4fb3f2448f6c2d5d17 to your computer and use it in GitHub Desktop.
Save nicholasodonnell/1218544f96c52e4fb3f2448f6c2d5d17 to your computer and use it in GitHub Desktop.
Renames all .html templates to use .twig extension. Used in legacy Craft CMS builds.
import os
import shutil
def rename(dir):
for subdir, dirs, files in os.walk(dir):
for file in files:
srcLocation = os.path.join(subdir, file)
destLocation = srcLocation.replace('.html', '.twig')
if not os.path.isfile(destLocation):
print srcLocation + ' -> ' + destLocation
shutil.move(srcLocation, destLocation)
def main():
rename('./')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment