You don't actually have to call the external basename command. You could use the following commands,instead:
$ s=/the/path/foo.txt
$ echo ${s##*/}
foo.txt
$ s=${s##*/}
$ echo ${s%.txt}
foo
$ echo ${s%.*}
foo
Note: This solution worksin all recent (post 2004) POSIX compliant shells, (e.g. bash, dash, ksh, etc.).