Viking, as ever thank you so much... I will get on with it now...
I have updated the script, one question does the test need to go up front, or is it ok below?
#!/bin/zsh
: <<'COMMENT'
Recursively drill into directory hierarchy for image files with no
extension. Exclude text files. Use exiftool to inspect the image
and extract FileType (extension), then rename with that extension.
Requires third-party exiftool installation.
Usage: addext.zsh /path/to/parent/directory
VikingOSX, 2020-05-22, Apple Support Communities, No warranties of any kind.
COMMENT
STARTDIR="$1:a"
setopt extended_glob
for f in ${STARTDIR}/**/*~*.txt(.N);
do
# print "${f}"
EXT=$(/usr/local/bin/exiftool -s3 "-FileType" "${f}")
mv "${f}" "${f}.${EXT}"
: <<'COMMENT'
Errata. In case there are any images that already have an extension,
we need to test for that, and ignore them.
The following change provides that extra precaution to avoid redundantly
adding to an existing extension. Update this code segment in the
previously provided script:
COMMENT
EXT=$(/usr/local/bin/exiftool -s3 "-FileType" "${f}")
# skip those files that already have an extension
[[ ${f:e} ]] && continue
mv "${f}" "${f}.${EXT}"
done
echo "Script has completed."