Removing trailing characters

I have been given a shell script that I need to amend. To do the following
extract the filename from the flag file by removing the .flag extension.

# Local variables
# Find if the flag files exists
MASK=coda_mil2*.flag
 
# Are there any files?
    bookmark="40"
    fileFound=0
    ls -1 $MASK > /dev/null 2>&1
    if [ $? -eq 0 ]
    then
        # Oldest file
        bookmark="50"
        fileName=$( ls -1 $MASK | head -n 1 )
        # Extract the coda file name
   fileNameCoda=$( echo $fileName | cut -f1-2 -d. ) ???????? 

It is this line I am struggling with I need to remove the file extension from the flag file to get the actual file name that I am going to process with SQL Loader further down the script this would be fine if the two files looked like this

myfile.flag
myfile

But my files look like this
myfile.001.002.flag
myfile.001.002
It is this string that I am trying to get "myfile.001.002"

What could I do to extract the filename when it has multiple dot?

 fileNameCoda=$( echo $fileName | cut -f1-2 -d. )

With this I get myfile not myfile.001.002

fileNameCoda=${fileName%.*} 

Hello,

Please use the code tags while posting. It's not clear. Could you please let us know the expected Output for same.

Thanks,
R. Singh

Thank you very much