troubleshooting Question

MS-DOS locate string in multi line text file then set to a variable

Avatar of ToddRod_Taylor
ToddRod_TaylorFlag for United States of America asked on
Microsoft DOSWindows OSWindows Batch
8 Comments1 Solution1543 ViewsLast Modified:
I would like to use MS-DOS FIND command (or some other method) in a batch to locate a string from  TEXTFILE.TXT and store it to a variable.  My text file has multiple lines, and the string I search for is always the same "StoreId="   However, it can be on different lines within the text file.  Always in the top 10 lines.  I am after the value of what StoreId equals for the contents of the variable.

Example line from text file: StoreId=st0028
DOS batch variable contents desired: 0028
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros