Well, that's a wrap.

bash
#!/bin/bash
# The "if grep" line means that "if file does not contain comma".
for f in *; do
if grep -q --exclude-dir='.' -- "," "$f"; then
NAMEDIR=$(basename "$f" | cut -d " " -f 3- | sed -E 's/\.(png|jpg|jpeg|txt|md)$//')
if [ ! -d "$NAMEDIR" ]; then
mkdir "$NAMEDIR"
fi
mv "$f" "$NAMEDIR"/"$f"
else
if [ ! -d multiplenames ]; then
mkdir multiple
names
fi
mv "$f" multiple_names/"$f"
fi
done

Thanks for the advice on awk — that led me to cut, which views fields in much the same way.