Skip to content

Instantly share code, notes, and snippets.

@kerolloz
Created December 9, 2018 20:24
Show Gist options
  • Save kerolloz/7e27007901eb6b37c9cb3f993ff1d260 to your computer and use it in GitHub Desktop.
Save kerolloz/7e27007901eb6b37c9cb3f993ff1d260 to your computer and use it in GitHub Desktop.
change filenames from .html to .php in current directory
import os
def rename_html_to_php():
for filename in os.listdir("."):
if os.path.isdir(filename):
os.chdir("./"+filename)
rename_html_to_php()
os.chdir("..")
if filename.endswith(".html"):
print(filename, "changed !")
os.rename(filename, filename.replace(".html", ".php"))
if __name__ == "__main__":
rename_html_to_php()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment