Strip extension (source)
Example: foo.png => foo
for file in *.png; do
echo $(basename $file .png)
done;
or
for file in *.png; do
echo ${file%%.*}
done;
example
for file in *.png; do
convert -flatten $file ${file%%.*}-flatten.png
done;
Extract extension from filenames (source)
Example: foo.png => png
for file in *.png; do
echo "${file##*.}"
done;
for file in *; do
[ "${file##*.}" != "txt" ] && echo $file
done
http://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash