![‘find’不是内部或外部命令可操作程序或批处理文件](https://linux22.com/image/1324680/%E2%80%98find%E2%80%99%E4%B8%8D%E6%98%AF%E5%86%85%E9%83%A8%E6%88%96%E5%A4%96%E9%83%A8%E5%91%BD%E4%BB%A4%E5%8F%AF%E6%93%8D%E4%BD%9C%E7%A8%8B%E5%BA%8F%E6%88%96%E6%89%B9%E5%A4%84%E7%90%86%E6%96%87%E4%BB%B6.png)
FIND
当我在嵌套FOR
循环和IF
批处理文件中的语句中使用该函数时出现此错误。
‘find’不是内部或外部命令可操作程序或批处理文件
我正在尝试查找目录中最大的文件:
SET /P number=Enter the number of files to find:
for /l %%x in (1,1,!number!) do (
for /r %%h in (*) do (
IF %%x GTR 1 IF !check! geq %%~zh (
IF !check! equ %%~zh (
echo !chkn!
FIND "!chkn!" Biggest.txt
IF %errorlevel% equ 1 set res=notfound
FIND "!chkp!" Biggest.txt
IF %errorlevel% equ 1 set res=notfound
IF "!res!" equ "notfound" (
IF !tes! LSS %%~zh (
SET tes=%%~zh
SET name=%%~nh
SET path=%%~ph
)
)
)
IF !tes! LSS %%~zh (
SET tes=%%~zh
SET name=%%~nh
SET path=%%~ph
)
)
IF %%x equ 1 (
IF !tes! LSS %%~zh (
SET tes=%%~zh
SET name=%%~nh
SET path=%%~ph
)
)
)
SET check=!tes!
SET chkn=!name!
SET chkp=!path!
echo !chkn!
echo !check!
echo %%x number: >> Biggest.txt
echo name = !chkn! >> Biggest.txt
echo size = !check! >> Biggest.txt
echo path = !chkp! >> Biggest.txt
echo file is created
SET tes=0
)
答案1
尽管缺乏细节,我猜你的“查找”命令不使用 c:\windows\system32\
这有用吗
SET /P number=Enter the number of files to find:
for /l %%x in (1,1,!number!) do (
for /r %%h in (*) do (
IF %%x GTR 1 IF !check! geq %%~zh (
IF !check! equ %%~zh (
echo !chkn!
c:\windows\system32\FIND "!chkn!" Biggest.txt
IF %errorlevel% equ 1 set res=notfound
c:\windows\system32\FIND "!chkp!" Biggest.txt
IF %errorlevel% equ 1 set res=notfound
IF "!res!" equ "notfound" (
IF !tes! LSS %%~zh (
SET tes=%%~zh
SET name=%%~nh
SET path=%%~ph
)
)
)
IF !tes! LSS %%~zh (
SET tes=%%~zh
SET name=%%~nh
SET path=%%~ph
)
)
IF %%x equ 1 (
IF !tes! LSS %%~zh (
SET tes=%%~zh
SET name=%%~nh
SET path=%%~ph
)
)
)
SET check=!tes!
SET chkn=!name!
SET chkp=!path!
echo !chkn!
echo !check!
echo %%x number: >> Biggest.txt
echo name = !chkn! >> Biggest.txt
echo size = !check! >> Biggest.txt
echo path = !chkp! >> Biggest.txt
echo file is created
SET tes=0
)