See the info manual for bash under 3.5.3 Shell Parameter Expansion.
You could also do:
srcfile=${1##*/} # subtract the longest prefix of $1 ending with
/
FILENOEXTENSION=${srcfile%.*} # subtract shortest suffix starting with .
OUTDIR=${1%/*} # subtract shortest suffix starting with /
## means match the longest possible pattern on the end, and delete it from the
beginning of the variable ($1 in this case). The pattern is */ and means delete
anything ending with a /.
If I'd used one # it would delete the shortest match to the pattern.
so if the $1 held /usr/local/lilypond/file.ly
srcfile=${1#*/}
would yield local/lilypond/file.ly, not very good, but with ## we get the whole
path off.
% means the same thing, only delete the matched part off of the end. There's
also a %% that means delete the longest match off the end.
There's also stuff for substring matches and string lengths, and offset to a
found match and more! Should work with bash, sh, and any shell compatible.
Probably not zsh, they're in a different universe.
Patrick