Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import os
  2. import re
  3.  
  4. for filename in os.listdir(os.getcwd()):
  5.     lowercase_season_regex = r"(summer|winter|spring|fall|autumn)"
  6.     season_matches = re.finditer(lowercase_season_regex, filename, re.MULTILINE | re.IGNORECASE)
  7.     for matchNum, match in enumerate(season_matches, start=1):
  8.         lowercased_season_file_name = filename.replace(match.group(), match.group().lower())
  9.         os.replace(filename, lowercased_season_file_name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement