I am migrating all my JavaScript files to typescript, first i need to convert my existing JavaScript file extensions to *.ts
To test i have following command, but this fail: used examples
for f in **/*.js; do
git mv "$f" "${f%.js}.ts"
done
I always seem to get:
fatal: not under version control, source=jscript/index.js, destination=jscript/index.ts
My final goal is to recursive go to my javascript folder and rename inplace from *.js to *.ts
Yeay!
The complete sollution in my case is a below, i hope somebody else can use this as well. just place in the root folder of your repo and adjust the folders you work with:
#!/usr/bin/env bash
shopt -s globstar
for f in /public/jscript/*.min.js public/jscript/**/*.min.js; do
git rm -r "$f"
done
# convert all the js files to ts files.
for f in public/jscript/**/*.js; do
git mv "$f" "${f%.js}.ts"
done
Seems like you forgot to add them to Git. Run :
git add --all :/
After that you should be able to rename. Though I would recommend committing first:
git add --all :/ && git commit -m update
Note:
If you haven't even initialized the repo, you will need to run git init before everything else.
As per your comment, it doesn't go into the sub-folders because you probably forgot to use globstar. Add the line
shopt -s globstar
before you use **.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With