On Tue, 3 Sep 2024 at 17:53, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
#!/usr/bin/zsh
filename=$1
extension="${filename##*.}"
(( $#filename == $#extension )) && extension=
if (( $#extension > 0 && $#extension < 6 )); then
filename="${filename%.*}"
else
extension=
fi
echo filename is: $filename
echo extension is: $extensionTry it on "/foo.bar/baz".You might be looking for ${filename:e}. It does not differentiate between short vs long extensions, but you probably shouldn't either.Roman