As Mark said, find return the number of lines that match in a file, not the number of individual strings in one line. To do so, you need to use another method, for example:
@echo off
setlocal EnableDelayedExpansion
set /a count = 0
for /f "delims=" %%a in ('dir "%~1" /a:-d /b') do (
for /F "delims=" %%b in ('find %2 ^< "%%a"') do call :next "%%b" "%~2"
)
echo found %count% occurances of "%~2"
pause
GOTO:EOF
:next
set num=0
set "line=%~1"
:nextMatch
set "line2=!line:*%~2=!"
if "!line2!" equ "!line!" goto endMatchs
set /A num+=1
set "line=!line2!"
if defined line goto nextMatch
:endMatchs
set /a count=count+num
For example:
C:> type 1.txt
An example of text file.
This example line have two "example" words.
End of example.
C:> test 1.txt "example"
found 4 occurances of "example"
findwill count the number of lines that match your string, so searching xyyx' for 'x' will count as one, even though the x's aren't in a row. If that's not what you want, you'll need a different tool.