1.

Solve : Search for multiple strings using batch?

Answer»

I have the following code
Code: [Select]@echo off

if not exist F:\acad\%2\nul goto error2
if "%1"=="" goto error
if "%2"=="" goto error
echo. Search results for all RAW data files: >c:\survey\null.
FOR %%F IN (f:\acad\%2\*.%2) DO FIND "5=%1" %%F >>C:\SURVEY\NULL.
FOR %%F IN (f:\acad\%2\*.%2) DO FIND "PT%1" %%F >>C:\SURVEY\NULL.
FOR %%F IN (f:\acad\%2\*T.%2) DO FIND "%1," %%F >>C:\SURVEY\NULL.
echo. >>c:\survey\null.
echo. GPS file search results: >>c:\survey\null.
FOR %%F IN (f:\acad\%2\GPS*.%2) DO FIND "%1," %%F >>C:\SURVEY\NULL.
echo. >>c:\survey\null.
echo. TFR file search results: >>c:\survey\null.
FOR %%F IN (f:\acad\%2\T*.%2) DO FIND "--%1" %%F >>C:\SURVEY\NULL.
echo.
CALL LN
REM echo. Type "LN" to view results.
echo.
goto end

:error
echo.
echo. **********************************************************************
echo. ***** USAGE: FINDPT [point number] [job] ******
echo. ***** EXAMPLE: To find point number 1254 in job number 511, ******
echo. ***** type "FINDPT 1254 511" followed by [RETURN]. ******
echo. **********************************************************************
echo.
goto end

:error2
echo.
echo. Invalid syntax, or directory "%2" does not exist.
goto error

:end

It works, but, it repeats the files it searches in for strings "5=%1", "PT%1", and "%1," so it makes my results list three TIME longer than it needs to be. How can I search for multiple strings with out it DISPLAYING the files searched three times?so what do you want show the output and show the supposed output



Discussion

No Comment Found