I have a folder with files named
input (1).txt
input (2).txt
input (3).txt
...
input (207).txt
How to rename them to
input_1.in
input_2.in
input_3.in
...
input_207.in
I'm trying this
for f in *.txt ; do mv $f `echo $f | sed -e 's/input\ (\(\d*\))\.txt/input_\1.in/'` ; done
But it gives me
mv: target `(100).txt' is not a directory
mv: target `(101).txt' is not a directory
mv: target `(102).txt' is not a directory
...
Where am I wrong?
Now I have added quotes, but now I get it
mv: `input (90).txt' and `input (90).txt' are the same file
It somehow tries to rename a file with the same name. How does this happen?
source
share