Guest User

Untitled

a guest
Sep 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. # Simply had a lot of files I needed to rename
  2. import os
  3.  
  4. # Get the current directory
  5. path = os.getcwd()
  6. # Gather all file names
  7. filenames = os.listdir(path)
  8.  
  9. # Loop through change all file endings from .htm to .xhtml.
  10. # changing to lowercase for readability, personal preference
  11. for filename in filenames:
  12. os.rename(filename, filename.replace(".htm",".xhtml").lower())
Add Comment
Please, Sign In to add comment