@echo off
setlocal
if ".%2" == "." goto usage
if not ".%4" == "." goto usage

rem verify that source file exists and contains messages (or is stdin)
if "%2" == "-" goto stdin
if exist %2 goto file_exist
echo Can't open %2
goto end

:file_exist

rem set name of catalog file
if ".%3" == "." set CATFILE=%1.cat
if not ".%3" == "." set CATFILE=%3

mkcatdef %1 %2 | gencat %CATFILE% -
echo.
goto end

:usage
echo usage: runcat catname srcfile [catfile]
:end
endlocal
@echo on
