I want to rename all files and directories that contain the word "special" to "regular". It should maintain case sensitivity so "Special" won't become "regular".
How can i do this in bash recursively?
Open the default file manager on Ubuntu, and choose all the files that you want to rename, right-click on them, and then click on 'Rename…', or use the 'F2' button. Now the rename window will open. You will have to enter the text, that will be used in all the names.
A solution using find
:
To rename files only:
find /your/target/path/ -type f -exec rename 's/special/regular/' '{}' \;
To rename directories only:
find /your/target/path/ -type d -execdir rename 's/special/regular/' '{}' \+
To rename both files and directories:
find /your/target/path/ -execdir rename 's/special/regular/' '{}' \+
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