Conditional File Selection From a Directory

I have a directory with files that was saved all along the day at different times. Every day I have to run a program that will select 50 files for each hour which has the maximum score.

Sample file name: a_b_c_d_e_f
where a,b,c,d,e,f are double values

Score calculation:
(a + b + c + d + e + f)*(size of the file)

Example:
Sample file name: 0.06_0.17_0.11_1.0_1.0_1.0
Size of the file: 2030 bytes
Score = (0.06 + 0.17 + 0.11 + 1.0 + 1.0 + 1.0)*2030

Likewise, it should calculate scores of all the files and select 50 having highest scores for each hour.

Have you tried anything at all? If so, post your code and error messages.

Regards,
Alister

This is how I am calculating the score of each file... splitting the filename and adding the parts and multiply it with the filesize....

Now what I am not able to do is to take files with 50 highest scores for every hour in the day ??

cd <folder>

for file in *.*
do
  
  # get the filename
  filename=$(stat -r $file | awk -F" " '{print $16}' )
  
  # get the filesize
  filesize=$(stat -r $file | awk -F" " '{print $8}' )
  
  # split the filename and store in an array
  IFS='_' read -a arr <<< "${filename}"
  
  # find the sum of the filename splitted float values
  total=0
  for i in ${arr[@]}; do
    total=`echo $total + $i | bc`;
  done

  # find the score of the file = (filesize * sum of the floats)
  score=$(echo $filesize $total | awk '{printf "%4.3f",$1*$2}')

done

Which os you are using what is the version of stat please?

I m using mac osx. Can't find version of stat.
Sorry..