Count total file downloaded using FTP

Hi All,

I'm developing a FTP script as below:

ftp -v -n <IP_ADDRESS> << EOF
user avery jSqaqUU2
lcd /directory/folder/
ascii
prompt
mget *
bye
EOF

I would like to enhance the script to count the total file downloaded. For example, once the script run i want the message "Total <n> files downloaded". How could i do this?:confused:

Thanks
Tarmizee

Count the files in the directory.

filect1=`ls | wc -l`

Do you ftp command
Count the files in the directory now.

filect2=`ls | wc -l`

Subtract, and that is your count of new files.

echo "$filect2 - $filect1" | bc