@echo off
set source=D:\Retro-Work


setlocal EnableDelayedExpansion
set folder=%cd%
cd work\out

copy %source%\make_booklet.php .\ /y
php -f make_booklet.php

cd odd
)

if NOT EXIST output mkdir output

for %%i in (*.tif) DO (
echo Converting %%i
convert %%i output\%%~ni.pdf
)

cd output
pdftk *.pdf cat output "%folder%\_odd.pdf"
rem del *.pdf /q

cd %folder%\work\out\even
)

if NOT EXIST output mkdir output

for %%i in (*.tif) DO (
echo Converting %%i
convert %%i output\%%~ni.pdf
)

cd output
pdftk *.pdf cat output "%folder%\_even.pdf"


pause
