Or, if this is a single operation, you can use vim:
> ls -al foo bar.txt foo baz.txt
Open vim and run:
:r!ls *.txt
This downloads the files and then does:
:%s/\(\(.*\)\.txt\)/mv "\1" "\2"/gc
This will replace the lines as follows:
mv "foo bar.txt" "foo bar" mv "foo baz.txt" "foo baz"
Highlight everything with Ctrl-v down, then type : and enter the remainder of this command:
:'<,'>!bash
This will execute the highlighted commands in bash. Exit vim and check your directory:
> ls foo bar foo baz
source share