Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Programming (http://www.go4expert.com/forums/programming-forum/)
-   -   Batch script that counts how many times a string appears in a file (http://www.go4expert.com/forums/batch-script-counts-times-string-t25270/)

Cleptography 17Mar2011 11:21

Batch script that counts how many times a string appears in a file
 
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 17Mar2011 11:45

Re: Batch script that counts how many times a string appears in a file
 
What the use of it??

Cleptography 17Mar2011 12:17

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

Originally Posted by RITESH KAKKAR (Post 80776)
What the use of it??

Its pretty self explanatory.
Don't troll me because you have nothing better to do.

RITESH KAKKAR 17Mar2011 12:26

Re: Batch script that counts how many times a string appears in a file
 
Hi, friend i have no idea about uP..!!

Cleptography 18Mar2011 02:02

Re: Batch script that counts how many times a string appears in a file
 
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 19Mar2011 16:39

Re: Batch script that counts how many times a string appears in a file
 
Please tell what it does?? i am new to computer language.


All times are GMT +5.5. The time now is 18:07.