Skip to content

Instantly share code, notes, and snippets.

Last active March 23, 2023 14:58
What would you like to do?
rename all *.js files containing React markup to *.jsx
find ./src -type f -name '*.js' -not -name '*.jsx' -not -name '*.ejs' -exec bash -c 'grep -l "</" $0' {} \; -exec bash -c 'mv "$0" "${0%.js}.jsx"' {} \;
Copy link

for files that don't have </ in them, you can run it with /> as well

Copy link

andokai commented May 19, 2022


Copy link


Copy link

jsakas commented Feb 24, 2023

@parties thanks for the snippet, worked great.

One suggestion, if using git, I changed mv to git mv.

find ./src -type f -name '*.js' -not -name '*.jsx' -not -name '*.ejs' -exec bash -c 'grep -l "</" $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