Help with findstr

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
J'aitreschaud
Posts: 11
Joined: 01 Jul 2018 21:35

Help with findstr

#1 Post by J'aitreschaud » 01 Jul 2018 21:48

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 :(

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Help with findstr

#2 Post by penpen » 01 Jul 2018 22:46

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

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Help with findstr

#3 Post by Squashman » 02 Jul 2018 06:24

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.

J'aitreschaud
Posts: 11
Joined: 01 Jul 2018 21:35

Re: Help with findstr

#4 Post by J'aitreschaud » 02 Jul 2018 10:36

@penpen Thanks :)
@Sqaushman Your solution worked! Thank you so much :mrgreen:

Post Reply