It’s surprising how often I need this…
@ECHO OFF
IF [%1] == [/?] GOTO USAGE
IF [%1] == [/h] GOTO USAGE
IF %1 NEQ +%1 GOTO USAGE
GOTO PROCESSING
:USAGE
ECHO Sudoku (killer difficulty) downloader, loads from https://sudoku-drucken.de
ECHO and assembles to single file, ready to be printed.
ECHO Dependencies are wget and pdftk, those need to be available on the PATH.
ECHO.
ECHO usage: sudoku [N]
ECHO N - Number of Sudoku pages, default 20 if omitted
GOTO END
:PROCESSING
SETLOCAL
SET FOLDER=%TEMP%\SUDOKU
MD %FOLDER%
CD /D %FOLDER%
SET PAGES=20
IF NOT %1==[] SET PAGES=%1
FOR /L %%N IN (1, 1, %PAGES%) DO (
wget -q -O %%N.pdf "https://sudoku-drucken.de/component/sudoku/?task=print_sudoku&level=killer"
ECHO Downloaded page %%N
)
ECHO Combining %PAGES% to a single PDF
pdftk *.pdf cat output sudoku.pdf
CALL sudoku.pdf
CD \
RMDIR /S /Q %FOLDER%
ENDLOCAL
:END
Leave a Reply