@echo off

if [%1]==[] goto usage
for %%i in ("%~1") do (
    set "FILENAME=%%~ni"
    set "EXT=%%~xi"
    set "DIR=%%~dpi"
)
call C:\10-develop\gitea\kabellaengen\bin\setenv.bat

REM echo Dateiname ohne Erweiterung: %FILENAME%
REM echo Erweiterung: %EXT%
REM echo Verzeichnis: %DIR%
REM
REM Namen der Ergebnisdateien
set RESULT_JSON=%FILENAME%_texts.json

if exist "%~dp0_setenv.bat" (
    echo Lade lokale Umgebungseinstellungen aus _setenv.bat...
    call "%~dp0_setenv.bat"
)
REM Zielverzeichnis
set TARGET_DIR=%PROJECT_WORK%
mkdir "%TARGET_DIR%"

echo.
echo === Extracting TEXT and MTEXT from DXF ===
call translate.bat --filename %FILENAME%%EXT% --extract -t json --outname %RESULT_JSON%
if not exist "%PROJECT_WORK%\%RESULT_JSON%
" (
    @echo == failed: extracting texts
    pause
    goto :eof
)
echo.
echo === Translation file created: %PROJECT_WORK%\%RESULT_JSON% ===
pause
goto :eof


:usage
@echo Usage: %0 ^<dxfinWorkOrdner.dxf^>
exit /B 1
goto :eof


