You loop over each file name with a bash script like this:
#!/bin/bash
for f in *
do
name=(${f//./ }) # split the filename on period. Note - the space matters!
number=(${f//\~/ }) # similar trick to find the number between tildes
newName=${name[0]}${number[1]}${name[1]} # construct the new name from array elements
echo "now you can rename " $f " to " $newName # print out the new name as a check
done
I deliberately left out the "rename" command, replacing it with an "echo" instead. See if this does what you wanted - then change the echo
line to
mv $f $newName
You might want to copy the files to a new directory, rather than doing a bulk rename, until you are sure things are behaving. I would not want to be responsible for a bunch of files getting overwritten or otherwise mangled. Of course this would be something like
mv $f newDirectory/$newName