about if statement

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

about if statement

#1 Post by goodywp » 13 Nov 2017 16:13

I have following code:

Code: Select all

:: MOCKUP
FIND /i "-08699-" <sch_pack.txt >>all_sch_pack.txt

:: QA_Infra
FIND /i "-08700-" <sch_pack.txt >>all_sch_pack.txt

:: NAR_Infra
FIND /i "-08680-" <sch_pack.txt >>all_sch_pack.txt

:: MY_Prof
FIND /i "-02220-" <sch_pack.txt >>all_sch_pack.txt

if %errorlevel% equ 1 ECHO empty>>all_sch_pack.txt
what I want is that if found, there will be no line saying "empty" in all_sch_pack.txt
But if found nothing, there will be one line saying "empty" in all_sch_pack.txt

Thanks

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

Re: about if statement

#2 Post by Squashman » 13 Nov 2017 16:55

Use FINDSTR instead. You can use all your search strings in one Search instead of four. Then you could check your error level from there or use conditional execution.

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: about if statement

#3 Post by goodywp » 17 Nov 2017 10:26

Thanks Squashman!

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

Re: about if statement

#4 Post by Squashman » 17 Nov 2017 13:09

You have used FINDSTR in your previous questions using the /G option. I guess you just needed a little poke to push you in the right direction again. Hopefully you are not standing next to a cliff the next time I poke you. :lol:

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: about if statement

#5 Post by goodywp » 27 Nov 2017 15:37

Thanks Squashman!!

I have a new requirement for this piece code now. So please ignore this topic for now. I might post a new topic later soon if i can not figure it out by myself...

goodywp

Post Reply