You can also use parameter expansion:
$ filename=foo.txt
$ echo "${filename%.*}"
foo
Just be aware that if there is no file extension, it will look further back for dots, e.g.
.bashrc
) it will remove the whole filename.path.to/myfile
or ./myfile
), then it will trim inside the path.