Looping in FTP session

Hi
I am trying rename multiple files in a remote location by connecting through FTP. How do i do this? I get error as for is not FTP command. I looked the FAQ for scripting but it is doesnt relate to my post.
Please help. Thanks

ftp -in >Error.log <<!
open $HOST
user $User $Pwd
for done_file in t*.txt
do
mv $done_file ${done_file}.done
done
bye
!

create a list of the files you want renamed - call it filename

mv file1 file2.done
mv myfile anotherfile.done
echo "
open  $hostname
user $user $pwd
$(cat filename)
bye 
" |  /usr/bin/ftp -in > ftp.log 

Could you explain please i am new to unix shell. How do i create a list of the files as the files are at the remote server.