looks like transfer.sh contains the sftp command which are to be used by sftp in batch mode.
Variables in tranfer.sh will not be expanded as sftp would treat this as text file with the list of commands in it.
You can try to generate the command file from within your script and the try to use like... something like..