1.

Solve : find string in txt file, return true value?

Answer»

hey all,

Is there a way to use the find command to return a true value, depending WEATHER the PROVIDED string is there??

example;

I want to search 1.txt for the word "November" but use the output as part of a if statement doing one thing if it's there and another if it's not.

any ideas??try to use the for with the find command LIKE this

for /F "tokens=2 delims=:" %%i in ('find /c "
November" 1.txt') do (
if "%%i" NEQ " 0" ( echo notexists ) else ( echo exists)


nice, cheers.

it tells me that 'echo' was unexpected at this time??!??

any ideas?sorry
just close the brackets of the do ( ADD ) at the end of ur code )this is what I got..


for /F "tokens=2 delims=:" %%i in ('find /c "
november" 1.txt') do (
if "%%i" NEQ " 0" ( echo notexists ) else ( echo exists)
)


but it's still telling me that "echo" was unexpected at this time.


GRRRRR fixed it,

for /F "tokens=2 delims=:" %%i in ('find /c "november" 1.txt') do (
if "%%i" NEQ " 0" ( echo notexists ) else ( echo exists)
)

Nice cheers for the help, dude.



thats good



Discussion

No Comment Found