Last active
August 29, 2015 14:23
-
-
Save tsur/47e0e477c1fe1a6c0f2c to your computer and use it in GitHub Desktop.
Replace file extensions recursively from *.js to *.es6
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
# Change .js and .es6 for whatever extension you like | |
for file in **/*.js;do mv $file $(echo ${file%*.*}.es6);done | |
# If wanna test it first then run | |
for file in **/*.js;do echo ${file%*.*}.es6;done | |
# Bash function, i.e. replaceExt(js, es6) | |
replaceExt () { | |
# If new extension is void/empty | |
if [ -z "$2" ]; then | |
for file in **/*.$1;do mv $file $(echo ${file%*.*});done | |
exit 0; | |
fi | |
for file in **/*.$1;do mv $file $(echo ${file%*.*}.$2);done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment