开发者

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

开发者 https://www.devze.com 2023-03-11 21:37 出处:网络
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 s

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 d开发者_如何学Goone 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


You could try a FOR-LOOP

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

精彩评论

暂无评论...
验证码 换一张
取 消