Skip to content

Instantly share code, notes, and snippets.

@tonilaukka
Forked from parties/renameReactJsToJsx.sh
Created September 14, 2023 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonilaukka/f79bfa067845986714482bdce0f20efc to your computer and use it in GitHub Desktop.
Save tonilaukka/f79bfa067845986714482bdce0f20efc to your computer and use it in GitHub Desktop.
rename all *.js files containing React markup to *.jsx
# finds all *.js files that have either `</` or `/>` tags in them and renames them to *.jsx
find ./src -type f -name '*.js' -not -name '*.jsx' -not -name '*.ejs' -exec bash -c 'grep -l -E "</|/>" "$0"' {} \; -exec bash -c 'mv "$0" "${0%.js}.jsx"' {} \;
@tonilaukka
Copy link
Author

If using git use git mv instead:

# finds all *.js files that have either `</` or `/>` tags in them and renames them to *.jsx
find ./src -type f -name '*.js' -not -name '*.jsx' -not -name '*.ejs' -exec bash -c 'grep -l -E "</|/>" "$0"' {} \; -exec bash -c 'git mv "$0" "${0%.js}.jsx"' {} \;

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