Last active
April 2, 2023 02:13
-
-
Save mt-shihab26/2e485729a7d43fff700a485e69b170c5 to your computer and use it in GitHub Desktop.
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 | |
| import shutil | |
| def convert_files(folder_path, old_ext, new_ext): | |
| for dirpath, dirnames, filenames in os.walk(folder_path): | |
| for filename in filenames: | |
| if filename.endswith(old_ext): | |
| old_file_path = os.path.join(dirpath, filename) | |
| new_file_path = os.path.splitext(old_file_path)[0] + new_ext | |
| shutil.move(old_file_path, new_file_path) | |
| # Example usage | |
| convert_files('src/components', '.jsx', '.tsx') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment