Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mt-shihab26/2e485729a7d43fff700a485e69b170c5 to your computer and use it in GitHub Desktop.

Select an option

Save mt-shihab26/2e485729a7d43fff700a485e69b170c5 to your computer and use it in GitHub Desktop.
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