I'm wondering if it's possible to have several %errorlevel% in the same script, or rather that %errorlevel% is overwritten by a new %errorlevel% as the script progresses?
I have a script which in 3 stages will search a text that's piped into "find" for 3 different specific strings. This works when there's only 1 stage searching for 1 string, but it won't work now that i added 3, the %errorlevel% won't update after the first stage, the result the errorlevel gets in the 1st stage remains throughout the script regardless of the 2 latter stages.
Here's a snippet of my script
Code: Select all
echo on
cd /D C:\
set fn=%~n1
mkvmerge.exe -i "%fn%.mkv" | find /I "Track ID 2: audio"
if %errorlevel% LEQ 0 (
goto:audiotrack2
)
if %errorlevel% GEQ 1 (
goto:extracttrack1
)
:extracttrack1
mkvmerge.exe -i "%fn%.mkv" | find /I "Track ID 1: audio"
if %errorlevel% LEQ 0 (
goto:audiotrack1
)
if %errorlevel% GEQ 1 (
goto:extracttrack3
)
:extracttrack3
mkvmerge.exe -i "%fn%.mkv" | find /I "Track ID 3: audio"
if %errorlevel% LEQ 0 (
goto:audiotrack3
)
if %errorlevel% GEQ 1 (
echo Error no audio track found
goto:exit
)
:audiotrack1
echo Audiotrack1
:audiotrack3
echo Audiotrack3
:audiotrack2
echo Audiotrack2
:exit
PAUSE
Ofcourse, piping from mkvmerge into a .txt file, and then using the find functions on the .txt file should be more resource efficient, however i believe i'd still get the same problem with the errorlevel.
Thanks for any help.
Regards,
KgOlve