Ssh newbie

What I am trying todo is: I want to create a script on mac that monitors a folder and merge the videa and the audio. But if file01 exists (previous merge file) I want it to create file02 and if this one exists I want it to create file03,... I would be very happy if the older files could be deleted because of disk space. But this one is tricky because I monitor the folder through folder action setup on mac. This is what I get so far:

!/bin/bash
now=$(date +"%d_%m_%Y_%Hu%M") 

cd "/Users/tomvanwinkel/Documents/Convert/Merge"
for filename in .mp4; 
do     
    stub="${filename%.}" 
    /usr/local/bin/ffmpeg -i "${stub}.mp4" -i "${stub}.wav" -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 "${stub}_ok".mp4
   FILE="${stub}_ok".mp4 
   if [ -f "$FILE" ]; 
   then     
      cp "${stub}_ok".mp4 "${stub}_ok01".mp4 
   fi
done

I can't quite follow this request, nor do I understand its relation to the title "Ssh newbie", but if you have a file name stub in a variable that, in real filenames, is followed by two digits, which in turn you want incremented, try

$ HN=$(ls $stub[0-9][0-9] | tail -1)
$ printf -vFN "$stub%02d" $((${HN##*[^0-9]} + 1))

$FN now has the filename with the number incremented by one.