Add filename, date and time at the bottom of image

REM ##########################################################
REM Make a copy of the original image and then add filename, date and time at the bottom of the copy(*%suffix%).
REM This script was created because I need to know the filename of the printed image.
REM It requires convert.exe and identify.exe.
REM ##########################################################
SET imgExt=jpg
SET suffix=.tx1.%imgExt%
 
del /q *%suffix%
 
FOR /F "delims=" %%i IN ('dir /b *.%imgExt%') DO (CALL :addlabel "%%i")
GOTO EOF
 
:addlabel
SET filename=%1
 
identify -format "%%[fx:w]x" %filename% > imginfo.txt
FOR /F "delims=\\n" %%i IN ('type imginfo.txt') DO (SET imgsize=%%i)
del /q imginfo.txt
 
SET fwnoq=%filename:"=%
convert %1 -background white  -fill black -size %imgsize% -pointsize 10 caption:"%fwnoq% - %date% - %time%" -append "%fwnoq%%suffix%"
 
SET imgsize=
SET filename=
 
:EOF