Created
July 28, 2023 07:38
-
-
Save bidwolf/8caade7c654a05d571dc6eab0cf3a370 to your computer and use it in GitHub Desktop.
Arquivo em python que renomeia todos os arquivos com nome index.js para index.jsx
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 rename_index_js_to_index_jsx(directory): | |
for root, _, files in os.walk(directory): | |
if directory == 'node_modules' | |
continue | |
for filename in files: | |
if filename == 'index.js': | |
old_path = os.path.join(root, filename) | |
new_path = os.path.join(root, 'index.jsx') | |
os.rename(old_path, new_path) | |
print(f"File '{filename}' in '{root}' has been renamed to 'index.jsx'.") | |
if __name__ == "__main__": | |
directory = '.' # Change this to the directory path where you want to start the search | |
rename_index_js_to_index_jsx(directory) |
Author
bidwolf
commented
Jul 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment