Batch script that counts how many times a string appears in a file

Cleptography's Avatar, Join Date: Sep 2010
Go4Expert Member
This simple example will count how many times a specified string appears in a file.
Code:
@echo off
 setlocal

set str2find=world
set file=%~1
set token=0

for /f "tokens=*" %%- in (%file%) do (
    set str=%%-&&call :NEXT
)
goto :COUNT

:NEXT
for /f "tokens=1,*" %%a in ("%str%") do (
    set str=%%b
    set strfind=%%a
)
if /i "%strfind%"=="%str2find%" set /a token=%token%+1
if "%str%"=="" goto :eof
goto :NEXT

:COUNT
echo.%str2find% was found %token% times.
RITESH KAKKAR's Avatar, Join Date: Mar 2011
Go4Expert Member
What the use of it??
Cleptography's Avatar, Join Date: Sep 2010
Go4Expert Member
Quote:
Originally Posted by RITESH KAKKAR View Post
What the use of it??
Its pretty self explanatory.
Don't troll me because you have nothing better to do.
RITESH KAKKAR's Avatar, Join Date: Mar 2011
Go4Expert Member
Hi, friend i have no idea about uP..!!
Cleptography's Avatar, Join Date: Sep 2010
Go4Expert Member
You are asking questions about 8085 processors and assembly language and you can't understand what this simple little batch script does.
Yes you are trolling me in a very childish manner.
RITESH KAKKAR's Avatar, Join Date: Mar 2011
Go4Expert Member
Please tell what it does?? i am new to computer language.