SFTP Multiple files

Hi :),
I am new to Unix and Shell Script
I have a urgent requirement, where i am new to shell script and Unix

my requirement is I have a files in a folder like

sales-prod-India-details.txt
sales-prod-japan-details.txt
sales-prod-china-details.txt

My SFTP server has

/Sales/location/India
/Sales/location/Japan
/Sales/location/China

each file to move to there respective folder using SFTP

India file must go to India folder under /sales/location
Japan file must go to Japan folder under /sales/location
China file must go to China folder under /sales/location

can any one help me with the shell script it will be much helpfull

thanks in advance

Assuming you have ssh keys setup for passwordless sftp

send()
{
    fname="$1"
    dir="$2"
    sftp remotenode<<-EOF
    cd $dir
    put "$fname"
    exit
EOF
}

cd /path/to/sendfiles
bdir="Sales/location/"
for f in *details.txt
do
     country="$(echo "$f" | awk -F '-' {print $3}' )"
     send "$f"  "${bdir}${country}"
done


This assumes that there is no need to mess with capitalization of the country in the file name. Your example is not clear on that. UNIX commands are VERY picky about capital versus lowercase letters

Untested, but something like...

#! /bin/bash

user="enter username here"
hostname="enter hostname here"

ls sales-prod-*-detail.txt | while read a
do
determinant=`awk -F\- '{print $3}'`
case ${determinant} in
        "[iI]ndia") 
                sftp ${a} ${user}@${host}:/Sales/location/India
                ;;
        "[jJ]apan")
                sftp S{a} ${user}@${host}:/Sales/location/Japan
                ;;
        "[cC]hina")
                sftp s{a} ${user}@${host}:/Sales/location/China
                ;;
esac

Hi thanks it looks so simple

as i am new to scripts can i know how this works in line

Thanks

---------- Post updated at 08:05 PM ---------- Previous update was at 07:29 PM ----------

I tried writing this can some one correct this if itis wrong

#! /bin/bash

CURRENT_FILES_PATH = "<CURRENT SOURCE FILE PATH>"
B2B_FILE_PATH = "<DESTINATION FILE PATH>"
user="enter username here"
hostname="enter hostname here"

FILES=CD CURRENT_FILES_PATH/*
for f in $FILES
do
l=`echo $f | cut -d "-" -f3`
echo "$f -> $l
echo $l;

sftp ${user}@${host}
cd ${CURRENT_FILES_PATH}
get ${f}
put ${B2B_FILE_PATH}/*$l*

EXIT
done