I encountered internet problem, so the details of my question never got posted in the original post for this topic. I will try again.
I need some help using multiple tokens in a DOS batch file. This is what I am trying to do;
1) I am trying to loop through a set of files within a folder.
2) I only want the files that has _ORD_ in the name.
3) Within each file are a set of 3 lines that has the same name (below is a sample of the file), but I am only interested in the one that has the letters MT in the second token.
4) I also want to see if the data in the 3rd token = “92095276680067”. If it is, then add 1 to the counter.
I cannot get the correct syntax when using more than 1 tokens. Any help will be greatly appreciated.
This is a copy of the DOS batch:
<pre> @echo off
for /f “tokens=2,3 delims= ” %%a in (‘find /I “MT” “%dir%\*_ORD_*”‘) do (
if /i “!Line:~0,13!”==”92095276680067″ set /a counter+=1
echo counter = %counter%</pre>
This is a sample of the file structure:
CONTACT Sam W
DUNNS RT 90124264390034
DUNNS MT 92095276680067
DUNNS VT 9115923262SSSS
Here is one way to evaluate which simplifies the script. Note since the split is on the space character (white spaces are the default), you do not need to specify delims.
SET /a counter=0
for /f “tokens=3″ %%a in (‘type “%dir%\*_ORD_*”^|findstr /i “MT”‘) do if /i “%%a”==”92095276680067″ set /a counter+=1
ECHO counter = %counter%</pre>
I also was able to try your codes using the FINDSTR and happy to report that it worked also. I now have learned another new way of achieving the same result.
Thanks again for your assistance.