Hi, I've reviewed several other solutions on this topic and nothing has seemed to work -- I was hoping someone could help analyze my code and figure out what I'm doing wrong.
My goal is to parse all the files in a directory and look for a specific string. If my string were "examplestring" I would need to look for files containing "example" but not "examplestring"
I realize the code I'm using to accomplish this is a tad circuitous, but I've been through many incarnations of this script and all have failed due to some of batch scripting's irregularities. The problem I'm seeing right now is that my variable "token" never gets set. When I pepper echo statements throughout the FOR loop, token always evaluates out to a blank variable.
Anyone have any ideas?
Below is the functional part of my code (there's some user input stuff and prompting for which folder to scan that I took out)
P.S. When I preview my code, it changes a tiny (but important) bit -- apologies if this explanation is unnecessary, but all of the SET statements that are &&'d or ||'d to FINDSTR read SET /a token<plussign><equalssign
FOR /F "DELIMS=" %%i IN ('DIR somedirectory /a-d /s /b') DO (
SET /a token=0
FINDSTR /I example %%i>nul && SET /a token+=1
IF %token% == 1 (
FINDSTR /I examplestring %%i>nul || SET /a token+=1
IF %token% == 2 (