Help to Modify File Name in each function before calling another function.

I have a script which does gunzip, zip and untar.

Input to the script is file name and file directory (where file is located)

I am reading the input parameters as follows:

 
FILENAME=$1
FILEDIR=$2

I have created 3 functions that are as follows:

 
1) gunzip file
2) unzip file
3) untar file

Say suppose the file name received is as follows:

I would to modify the file name to "mdm_ind_usa.2031.fsacm.tar.zip" after gunzip is done in gunzip function is called
Now file name should become

I would to modify the file name to "mdm_ind_usa.2031.fsacm.tar" after unzip is done in unzip function is called.
Now file name should become

and after untar function

Help is appreciated in order modify the filename as required.
Please Note: File Name passed to script could have any number of "." and "_". The file name i provided is for example purpose only.
Actually file name would vary.

With any shell that recognizes POSIX shell syntax (such as bash and ksh), try:

#!/bin/ksh
FILENAME=$1
FILEDIR=$2
printf "Start: FILENAME=%s, FILEDIR=%s\n" "$FILENAME" "$FILEDIR"
FILENAME=${FILENAME%.*}
printf "After stripping 1 extension:\tFILENAME=%s\n" "$FILENAME"
FILENAME=${FILENAME%.*}
printf "After stripping 2 extensions:\tFILENAME=%s\n" "$FILENAME"
FILENAME=${FILENAME%.*}
printf "After stripping 3 extensions:\tFILENAME=%s\n" "$FILENAME"

When invoked as:

tester mdm_ind_usa.2031.fsacm.tar.zip.gz /home/dir

it produces the output:

Start: FILENAME=mdm_ind_usa.2031.fsacm.tar.zip.gz, FILEDIR=/home/dir
After stripping 1 extension:	FILENAME=mdm_ind_usa.2031.fsacm.tar.zip
After stripping 2 extensions:	FILENAME=mdm_ind_usa.2031.fsacm.tar
After stripping 3 extensions:	FILENAME=mdm_ind_usa.2031.fsacm

Thanks this works.!!