Why not keep it simple?
#!/bin/zsh
for f in /test_data/*; do
str=$f
root=${str%/*} #Remove everything from the right to the first / from the right
name=${str##*/} #Remove everything from the left to the last / from the left
echo "Root = " $root
filename=$(echo $name | awk -F . '{print $1}')
extension=$(echo $name | awk -F . '{ print $2 }')
echo "Name = " $filename
echo "Extension = " $extension
done;
If there is no extension, then the variable will be empty