Looking for text in a file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Docfxit
Posts: 14
Joined: 12 Nov 2015 12:42

Looking for text in a file

#1 Post by Docfxit » 31 Jan 2019 11:38

I am writing out a file and trying to find some text in the file. It isn't finding the text.

Code: Select all

Bootrec /scanos >"%~dp0BootFixerTest.txt"
type "%~dp0BootFixerTest.txt" |find /i "Windows installations: 0" >nul || goto :Done
Pause
:Done
The file has in it:

Code: Select all

Scanning all disks for Windows installations.

Please wait, since this may take a while...

Successfully scanned Windows installations.
Total identified Windows installations: 0
The operation completed successfully.
I would like it to go to Done but it doesn't.

Docfxit
Last edited by Docfxit on 31 Jan 2019 16:04, edited 2 times in total.

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

Re: Looking for text in a file

#2 Post by Squashman » 31 Jan 2019 15:53

The code snippet and input example you provided works as provided. Must be something you are not showing us.

Docfxit
Posts: 14
Joined: 12 Nov 2015 12:42

Re: Looking for text in a file

#3 Post by Docfxit » 31 Jan 2019 16:04

Thank you for taking a look at it.

The only thing I have is a pause after the line. (I have added the pause in my example)

The script goes to the pause instead of going to Done.

Thanks,

Docfxit

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

Re: Looking for text in a file

#4 Post by Squashman » 31 Jan 2019 16:06

Why would it go to done? The double pipe does not mean TRUE (Successfule). It means false (unsuccessful). The only way it will go to done is if it doesn't find it.
https://www.robvanderwoude.com/condexec.php

Docfxit
Posts: 14
Joined: 12 Nov 2015 12:42

Re: Looking for text in a file

#5 Post by Docfxit » 31 Jan 2019 17:23

That's supper. That fixed it for me.

It's really great of you to point out what is / should happen.

Thank you very much,

Docfxit

Post Reply