My previous post missed the replacement * in sed 's/[.][^.]*$/*/'.
But still this is different from the original while loop: it does not add the * when there is no .xxxx extension.
BTW your last post has ICODE tags instead of Code tags. The latter work much better for multi-line code blocks.