我正在尝试回答这个问题的代码:
我试过这个:
# Rename all *.js to *.ts
for f in *.js; do
mv -- "$f" "${f%.js}.ts"
done
然而这会导致这样的结果:
Oles-MacBook-Pro:src oleersoy$ ./rename.sh
mv: rename *.js to *.ts: No such file or directory
我也尝试过这个:
rename js ts *.js
结果是:
Bareword "js" not allowed while "strict subs" in use at (eval 2) line 1.
想法?
答案1
好的 - 在 SO 上找到了这个:
https://stackoverflow.com/questions/21985492/recursively-change-file-extensions-in-bash
这有效:
find . -name "*.t1" -exec rename 's/\.t1$/.t2/' '{}' +