The variable PS1 is being used only in interactive shell, to access it you need to start your script with bash -i rename.sh.
Minimal example:
$ echo 'echo $PS1' > test
then compare
$ bash test
$ bash -i test
To run the script directly as an executable, add the following to the initial line
#!/bin/bash -i
Notice this works only if you chmod and run the script directly (e.g. ./rename.sh), and not with bash rename.sh, otherwise you'll have to call bash -i rename.sh again.
Edit
To change the terminal title directly, you can echo the control codes directly. Try
echo -e '\033]2;SomeTitle\007'
or, inside a script, with variables
title="SomeTitle"
echo -e '\033]2;'$title'\007'