Your script would fetch you the last modified file name from location /opt/automation/repository/hosts//opt/automation/repository/hosts/ on server some_servername1some_servername1
And when you doing scpscp you are ignoring the path and fetching the file name.
Please change the command from
**scp -r some_server_name1:~/"$cmdv" **
scp -r some_server_name1:~/"$cmdv"
to
scp -r some_server_name1:/opt/automation/repository/hosts/"$cmdv"
scp -r some_server_name1:/opt/automation/repository/hosts/"$cmdv"
Hope this solves the issue.