Last active
October 31, 2025 17:04
-
-
Save idolpx/6b0fb11f5f409efbddd3f76703b582e6 to your computer and use it in GitHub Desktop.
Rename all files and folders recursively from current directory to lowercase
This file contains hidden or 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
| #!/usr/local/bin/python3 | |
| import os | |
| list = [] | |
| dirlist = [os.getcwd() + '/'] | |
| # Build recursive list for dirs and files | |
| while len(dirlist) > 0: | |
| for (dirpath, dirnames, filenames) in os.walk(dirlist.pop()): | |
| dirlist.extend(dirnames) | |
| list.extend( map(lambda n: os.path.join(*n), zip([dirpath] * len(dirnames), dirnames)) ) | |
| list.extend( map(lambda n: os.path.join(*n), zip([dirpath] * len(filenames), filenames)) ) | |
| # Iterate through list backwards and rename files and folders | |
| for x in range(len(list) -1, -1, -1): | |
| item = list[x] | |
| print(f'{item} >>> {item.lower()}') | |
| os.rename(item, item.lower()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment