Globstar (bash >=4)
shopt -s globstar # Set the SHell OPTion globstar
for f in **/*.js; do
git mv "$f" "${f%.js}.$version.js"
done
To move everything to a single directory:
for source in **/*.js; do
dest="${source%.js}.$version.js"
dest="$destination/${dest##*/}" # Strip off leading directories and prepend actual destination
git mv "$source" "$dest"
done
Find
You can use find
, but it's almost the same, so save this for where you need Bash 3 or POSIX sh portability (OS X, for example).
find . -iname '*.js' -exec sh -c 'for f; do
git mv "$f" "${f%.js}.$version.js"
done' _ {} +