Last active
July 25, 2017 15:03
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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