Batch renaming using shell script
That is because bash for
split the element with space ' ' so you are commanding it to move 'input
' to '(1)
'.
The way to solve this is to tell bash to split by new line using IFS
variable.
Like this:
IFS=$'\n'
Then do your command.
However, I suggest you to use find
to do this instead using -exec
command.
For example:
find *.txt -exec mv "{}" `echo "{}" | sed -e 's/input\ (\([0-9]*\))\.txt/input_\1.in/'` \;
NOTE: I write this from memory and I did test this so let try and adjust it.
Hope this helps.