1.

Solve : Perform action on find?

Answer»

Ok, I need a bat file to do the following thing; he must find a certain string in a file (a *.CFG file) and perform an action (SET a var), how can I do that?

Thank youDepending on WHETHER you find what you're looking for you can TRY something like this:

find "arg" filename.ext
if %errorlevel%==0 set var=

Note: if you don't find arg then the errorlevel is 1

If you need a variable value from the file you're searching then you need to redirect the output of the FIND CMD and then use FOR loop logic.

The more complex the logic, the more useful VB Script becomes.

Hope this helps.

it worked, thank you



Discussion

No Comment Found