-1

I have a text file text.txt. The content of the file is:

--a-- W32i   APP ENU    12.0.1.61053 shp

I need to extract (via command line) the portion 12.0.1.61053.

This value is in the first line, at position 25 to 36.
I need to insert this value into an environment variable.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Jake
  • 1
  • 1
  • 4
    Possible duplicate of [Extract specific text from text file using batch](http://stackoverflow.com/questions/21260587/extract-specific-text-from-text-file-using-batch). Please take the time to do at least a basic search for similar existing questions before posting a new one. Thanks. – Ken White Nov 25 '15 at 00:10
  • 2
    Also SO is a programmer-to-programmer website for programmers to help other programmers solve problems. So you should show what you've tried and what problems you are having with your approach. – Χpẘ Nov 25 '15 at 00:35

1 Answers1

1

This is pretty straightforward. The code assumes that text.txt is in the same directory as your script.

@echo off

:: Get the first line of text.txt and store the entire thing in a variable
set /p first_line=<text.txt

:: Get an 11-character substring starting at position 25 (substrings start at 0)
set first_line=%first_line:~24,12%

echo %first_line%
SomethingDark
  • 13,229
  • 5
  • 50
  • 55