Skip to content

Instantly share code, notes, and snippets.

@tsur
Last active August 29, 2015 14:23
Show Gist options
  • Save tsur/47e0e477c1fe1a6c0f2c to your computer and use it in GitHub Desktop.
Save tsur/47e0e477c1fe1a6c0f2c to your computer and use it in GitHub Desktop.
Replace file extensions recursively from *.js to *.es6
# 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