Created
December 15, 2021 14:09
-
-
Save dsbilling/af3b48e1fdb619b3a4f012ceaeeba76b to your computer and use it in GitHub Desktop.
Rename files in current directory and sub-directories
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
| import os | |
| def process_directory(root): | |
| for root, dirs, files in os.walk(root): | |
| for name in files: | |
| if name.endswith(".new"): | |
| print("Renamed -> ", name) | |
| os.rename(os.path.join(root, name), os.path.join(root, name.replace(".new", ""))) | |
| process_directory(os.path.dirname(os.path.realpath(__file__))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment