I have multiple files with this format: this-is-text_r_123.txt and this-is-text.txt.
What I would like to do (preferable using a for loop) is to rename all this-is-text.txt files to their corresponding this-is-text_r_123.txt matches but have an i instead of the r in the file name. Considering that this-is-text is a random text (different from one file to another) and the 123 in the example above is any combination of 3 numbers. All files are in one directory.
I tried with mv and rename but I wasn't successful
I've searched and reviewed all the file renaming questions here but none matched my case
I changed the technology to Python to demonstrate how to do this in a language more convenient than bash:
For following set of files:
this script will produce:
You should be able to move files with this.
As you see, it works.
If you really need doing this in bash, it should be easy to port using
sedorawk.