I would like to write a function which is to perform "find" command with another embedded command, %recent% in another directory(share drive).
Below is the idea:
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%
Apparently it is not working.
Your advice will be much appreciated! :)
The DIR /D
and /B
options are not compatible - the /B
option overrides the /D
option.
Your FOR /F loop also needs to know what path to look in, not just your FIND commnad. The simplest thing to do is change your current directory to your desired path.
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%