我想写一个函数,用另一个嵌入式命令执行“find”命令,%recent%在另一个目录(共享驱动器)中。
以下是这个想法:
REM Take in log file name input eg. "result_10030" = %1 to search for all result_10030*.log = %1*.log
REM Use the following to list the files matching result_10030*.log
for /f "delims=" %%x in ('dir /d /od /b %1*.log') do set recent=%%x
echo %recent%
REM Use %recent% as the file to perform find
REM Take in %2 as share drive path
find "PASSED" %2%recent%
显然它不起作用。
非常感谢您的建议! :)
答案 0 :(得分:0)
DIR /D
和/B
选项不兼容 - /B
选项会覆盖/D
选项。
您的FOR / F循环还需要知道要查看的路径,而不仅仅是您的FIND commnad。最简单的方法是将当前目录更改为所需的路径。
pushd %2
for /f "delims=" %%x in ('dir /d /od /b "%~1*.log"') do set "recent=%%x"
echo %recent%
find "PASSED" "%recent%"
set rtn=%errorlevel%
popd
exit /b %rtn%