REM ***************************************************************************************** REM This batch file *must* be run with "delayed variable expansion" enabled REM (see the help for CMD.EXE for an explanation of DVE). Run like this at the commandline: REM REM CMD.exe /V /C mix.cmd REM REM in case of good luck the option SETLOCAL ENABLEDELAYEDEXPANSION does it REM REM ***************************************************************************************** SETLOCAL ENABLEDELAYEDEXPANSION IF "%3"=="" GOTO USAGE REM The following line is needed, because I scanned in reverse order del tempfile.pdf pdftk B=%2 cat Bend-1 output tempfile.pdf REM ***************************************************************************************** REM Seitenzahlbestimmung mit pdftk REM ***************************************************************************************** pdftk %1 dump_data | find "NumberOfPages" > temp.txt for /F "tokens=2,3* delims= " %%i in (temp.txt) do set PAGECOUNT=%%i del temp.txt REM set PAGECOUNT=%4 REM ***************************************************************************************** REM Ende Seitenzahlbestimmung REM ***************************************************************************************** set cmd=cat for /L %%i in (1,1,%PAGECOUNT%) do SET cmd=!cmd! A%%i B%%i pdftk A=%1 B=tempfile.pdf %cmd% output %3 GOTO END :USAGE ECHO "USAGE: mix_pdf.cmd inputfile1 inputfile2 outputfile pagecount :END