I have A.js
, B.js
, C.js
in a certain directory and I want to write a SINGLE command line in bash shell to rename these files _A, _B, _C. How can I do this?
I tried find -name '*.sh' | xargs -I file mv file basename file .sh
but it doesn't work, basename file .sh isn't recognized as a nested command
How about
rename 's/(.*).js/_$1/' *.js
Check the syntax for rename on your system.
The above command will rename A.js
to _A
& so on.
If you want to retain the extension, below should help:
rename 's/(.*)/_$1/' *.js
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