Code: Select all
@echo off
setlocal EnableDelayedExpansion
echo 1 - Brightfield
echo 2 - B-R Merged
echo 3 - B-G Merged
echo 4 - UV red
echo 5 - UV green
set /p CHOICES=Type in the numbers (space delimited) of the types you want:
echo.
set REGEX=%CHOICES%
set REGEX=%REGEX:1=^^^^.*Brightfield.*$ %
set REGEX=%REGEX:2=^^^^.*B-R.*$ %
set REGEX=%REGEX:3=^^^^.*B-G.*$ %
set REGEX=%REGEX:4=^^^^.*UV[ ]*red.*$ %
set REGEX=%REGEX:5=^^^^.*UV[ ]*green.*$ %
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set THEDATE=%%a-%%b)
for /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set THETIME=%%a%%b)
set FILECOUNT=0
set n=0
set PAGENUM=
set PAGENUMPREFIX=
for /f "delims==" %%f in ('dir /b /s ^| findstr /r "%REGEX%"') do (
set /a FILECOUNT+=1
)
if !FILECOUNT! gtr 8 (
set PAGENUMPREFIX=_
set PAGENUM=1
)
echo|set /p=Found !FILECOUNT! image(s), working...
for /f "delims==" %%f in ('dir /b /s ^| findstr /r "%REGEX%"') do (
convert "%%f" -pointsize 40 -size 1600x -gravity south -splice 0x150 -gravity south caption:"%%~nf" -composite "%%~nf_tmp%%~xf"
)
for /f "delims==" %%f in ('dir /b /s ^| findstr /r ".*_tmp\.tif$ .*_tmp\.tiff$"') do (
set FILE=!FILE!"%%f"
set /a n+=1
if !n! == 8 (
montage !FILE! -tile x4 -geometry 1450x1450+75+0 -quiet "!THEDATE!_!THETIME!!PAGENUMPREFIX!!PAGENUM!".png
convert "!THEDATE!_!THETIME!!PAGENUMPREFIX!!PAGENUM!".png -gravity center -extent 4960x7016 "!THEDATE!_!THETIME!!PAGENUMPREFIX!!PAGENUM!".png
set n=0
set /a PAGENUM+=1
set FILE=
)
)
if !n! gtr 0 (
montage !FILE! -tile x4 -geometry 1450x1450+75+0 -quiet "!THEDATE!_!THETIME!!PAGENUMPREFIX!!PAGENUM!".png
convert "!THEDATE!_!THETIME!!PAGENUMPREFIX!!PAGENUM!".png -gravity center -extent 4960x7016 "!THEDATE!_!THETIME!!PAGENUMPREFIX!!PAGENUM!".png
)
for /f "delims==" %%f in ('dir /b /s ^| findstr /r ".*_tmp\.tif$ .*_tmp\.tiff$"') do (
del "%%f"
)
echo|set /p=done.
if !PAGENUM! gtr 0 (
echo !PAGENUM! pages created.
) else (
echo 1 page created.
)
pause