Here is the script I came up with. Notice I tried to use cut to get the substring but it didn’t work since it’s too slow and I got empty value.
#!/bin/bash
#loop thru the images
yesterday=`TZ=EST+24 date +%Y%m%d`
count=0
for file in ${yesterday}/*.jpg
do
count=$((count+1))
#timeStr= echo "$file"|cut -c 26-29
timeStr=${file:25:4}
echo "$file"
convert "$file" -gravity south -stroke '#000C' -strokewidth 2 -annotate 0 "$timeStr" -stroke none -fill white -annotate 0 "$timeStr" "$file"
done
echo $count