Windows NT/Windows NT Batch File

Advertisement


Question
Hi Chris,

Below is a short example of my batch file:

set blah=823182
type %temp%\patches.txt | find "%blah%"
if errorlevel 1 echo "%blah% missing"
set blah=826232
type %temp%\patches.txt | find "%blah%"
if errorlevel 1 echo "%blah% missing"
set blah=828035
type %temp%\patches.txt | find "%blah%"
if errorlevel 1 echo "%blah% missing"
set blah=828749
type %temp%\patches.txt | find "%blah%"
if errorlevel 1 echo "%blah% missing"

What I want to do is make this a little more elegant by using a loop though my list of 823182, 826232, 828035, 828749 such as

set blah = 823182 826232 828035 828749

and then using a for loop and pipe (|) for my find but I can't get it to work so I have no choice but to do this clumsy list of instructions which works fine but is not pretty. Basically patches.txt is a text list and if I don't find an entry in this list I print out "missing" it's just a simple little program.

Thanks!

Marc

Answer
Hi Marc,

To be honest, I'm not sure if that's possible within DOS. Yes, a loop would be more elegant, but I didn't see much about loop programming in DOS that would apply to this situation. Did you have any starting points or references that you were already pursuing?

Cheers,

Chris

Windows NT

All Answers


Answers by Expert:


Ask Experts

Volunteer


Chris Schuh

Expertise

I have several years of schooling in this area (including post-secondary), and also several years in the work force. This is my career, and I love helping others out with computer problems. I possess excellent written communication skills which allows me to guide people through complicated solutions to their problems with relative ease. Outside of helping people with their computer issues, I'm also a Professional Magician and a Musician. You can check me out at www.chrisschuh.com!

©2012 About.com, a part of The New York Times Company. All rights reserved.