【发布时间】:2025-11-28 08:10:01
【问题描述】:
我正在尝试开发一个 Windows 批处理程序,如果出现 The system cannot find the drive specified. 或 The system cannot find the path specified. 之类的错误,则可以检查“fld_chk.out”文件并进行循环。
但是 cd A:\rr\Br>fld_chk.out 没有捕获这些错误。
如何捕捉标准错误?
我的代码是这样的:-
cd A:\rr\Br>fld_chk.out
cd B:\yy\dd>>fld_chk.out
find /c "The system cannot find" *.out>fld_count_check_1.out
find /c "0" fld_count_check_1.out>fld_count_check_2.out
FOR /F "TOKENS=1* DELIMS=:" %%B IN (fld_count_check_2.out) DO SET b=%%C
set _count=%b%
IF %_count% EQU 2 goto Success
IF not %_count% EQU 2 goto notSuccess
:Success
echo folder found
:notSuccess
echo folder not found
提前致谢 斯里
【问题讨论】: