-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-pdfstruct.cmd
More file actions
53 lines (42 loc) · 1.18 KB
/
run-pdfstruct.cmd
File metadata and controls
53 lines (42 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@echo off
REM Batch-process every PDF in the playground folder through pdfstruct.cli.
REM
REM For each <name>.pdf, produces:
REM <name>\<name>.md - extracted markdown
REM <name>\page-NNN.png - debug image overlays
REM
REM Usage:
REM run-pdfstruct.cmd
REM run-pdfstruct.cmd D:\some\folder
setlocal enabledelayedexpansion
set "PLAYGROUND=%~1"
if "%PLAYGROUND%"=="" set "PLAYGROUND=%~dp0playground"
set "CLI=%~dp0src\PdfStruct.Cli\bin\Debug\net8.0\pdfstruct.cli.exe"
if not exist "%CLI%" (
echo CLI not found: %CLI%
echo Build PdfStruct.Cli first.
exit /b 1
)
if not exist "%PLAYGROUND%" (
echo Playground folder not found: %PLAYGROUND%
exit /b 1
)
set "COUNT=0"
set "FAILED=0"
for %%F in ("%PLAYGROUND%\*.pdf") do (
set /a COUNT+=1
set "NAME=%%~nF"
set "OUTDIR=%PLAYGROUND%\!NAME!"
set "MDPATH=!OUTDIR!\!NAME!.md"
echo [!NAME!] %%~nxF
if not exist "!OUTDIR!" mkdir "!OUTDIR!"
"%CLI%" extract "%%F" --output "!MDPATH!" --debug-image "!OUTDIR!"
if errorlevel 1 (
set /a FAILED+=1
echo FAILED with exit code !errorlevel!
)
)
echo.
echo Total: %COUNT% files, %FAILED% failed
if %FAILED% gtr 0 exit /b 1
endlocal