I’m learning the ins and outs of batch programming, and I’ve hit a small snag. I’m trying to recursively loop through a directory (and subdirs) to find suitable .vob files. All is well, except my dir command is outputting File Not Found. In the command line, I can redirect the error to oblivion using:
dir /b *.vob 2>NUL
In the batch file, however, I get the blink of death.
for /R %%G IN (\) DO (
pushd "%%G"
for /F "usebackq" %%V in (`dir /b *.vob`) DO (
echo: Found %%~nV in %%~dpV
)
popd
)
Changing it to
for /R %%G IN (\) DO (
pushd "%%G"
for /F "usebackq" %%V in (`dir /b *.vob 2>NUL`) DO (
echo: Found %%~nV in %%~dpV
)
popd
)
My cmd window, I assume, crashes. Blinks on and off.
Debugging batches sucks, btw.
You need to escape the redirect
2^>NUL, then it should work as expected.