Page 1 of 1

Help with findstr

Posted: 01 Jul 2018 21:48
by J'aitreschaud
Bonjour everyone.
I'm having a problem with findstr right now. I have some text like this:

Code: Select all

:::. Path is
:::. Your name is
:::. Folder is
And I use this to output the text.

Code: Select all

FOR /F "tokens=* delims=:." %%H in (findstr /bl :::. "%~f0"') do @echo %%H
It works fine. At the top, I also have this code:

Code: Select all

SET PATH=%~dp0Files
IF not exist "%PATH%" (
    MKDIR %PATH%&CALL :MAKEFILES
)
For some reason, when I run it alone, the findstr command works fine. But when I add the above block of code, I get "The system cannot find the file findstr" and its wracking my brain why it doesn't work. When I take out the above code, however, it works perfectly fine. Any help is greatly appreciated :(

Re: Help with findstr

Posted: 01 Jul 2018 22:46
by penpen
Hello J'aitreschaud and welcome to this forum.
If the findstr statement is working out of loop, then you probably just missed one character within the for loop (untested):

Code: Select all

FOR /F "tokens=* delims=:." %%H in ('findstr /bl :::. "%~f0"') do @echo %%H
penpen

Re: Help with findstr

Posted: 02 Jul 2018 06:24
by Squashman
You are overwriting the system PATH variable. When you did that, it can no longer execute the FINDSTR command because the location of the FINDSTR command is searched for within the system PATH variable.

Re: Help with findstr

Posted: 02 Jul 2018 10:36
by J'aitreschaud
@penpen Thanks :)
@Sqaushman Your solution worked! Thank you so much :mrgreen: