Maikeru Konare
Maikeru Konare

Reputation: 31

Reading From a Text File and Executing What You Find

I can't figure out how to do what it says in the title. I have a text file apple.txt with:

set apple=7

and a file saved as a batch with

findstr /v "zzzzzzzzzzz" apple.txt

and when I run the batch file it displays "set apple=7" instead of actually setting the variable apple to 7. I'm assuming findstr adds an echo before each line but I don't know. I used the CMD with findstr /? but I can't figure this out.

Upvotes: 0

Views: 32

Answers (2)

zam664
zam664

Reputation: 767

I am not sure what you are doing with the find string. But if you have a file named out.txt with the following code:

dir

And from the command line you type:

cmd < out.txt

The contents of the file is piped into the command line processor.

Upvotes: 0

Magoo
Magoo

Reputation: 79983

FOR /f "delims=" %%i IN (apple.txt) DO %%i

should do that

Upvotes: 1

Related Questions