Dave
Dave

Reputation: 11

set a variable to a line within a text file containing a known value?

I'm having problems trying to create a batch script that will search through a txt file in a directory for a value "drawing_revision" and then take the line from this and extract the revision and set it as a variable I can use as a prefix on file names.

DRAWING_REVISION 00 TYPE: String

Has anyone done anything like this before? there doesn't seem to be much on using the line within the text file as a variable rather than the file name.

Thanks

Dave

Upvotes: 1

Views: 360

Answers (1)

jeb
jeb

Reputation: 82247

You could try a FOR-LOOP

for /F "usebackq tokens=2" %%a IN (`findstr DRAWING_REVISION myfile.txt`) do (
  echo Draw-Rev = %%a
)

Upvotes: 1

Related Questions