Skip to content

Instantly share code, notes, and snippets.

@bidwolf
Created July 28, 2023 07:38
Show Gist options
  • Save bidwolf/8caade7c654a05d571dc6eab0cf3a370 to your computer and use it in GitHub Desktop.
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
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)
@bidwolf
Copy link
Author

bidwolf commented Jul 28, 2023

Ele vai ignorar a pasta node_modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment