0

What Windows/DOS command line utility would one use to find 17 characters, starting at the 45th command line position of a daily revised text file?

Can this be done with 'TYPE'?

Sample daily text file contents:

XXXX_XXXXX.txt:XXXX (XXXXXXXXXXXXXX:(none)): 01-25-16 05:26AM XXXXXXXXX XXXXXXX.zip

Thanks.


I assume it could be done by a combination of SET and TYPE.

How would you define a variable as the text within a text file (which will only be one line (by using FINDSTR))?

Thanks.

2
  • My problem was resolved. I used SET to assign a variable from the text file [Example: SET /p variable=<X:\Text_File.txt], then SET another variable to select the date and time information from that set text format. [Example: SET Export_date_time=%variable:~30,17%]
    – noni
    Jan 26, 2016 at 16:22
  • Please read Can I answer my own question?. You might want to convert your comment into an answer ;)
    – DavidPostill
    Jan 27, 2016 at 23:06

1 Answer 1

0

My problem was resolved. I used SET to assign a variable from the text file:

Example: SET /p Directory_Contents=Text_File.txt

(Actually, a '<' is also supposed to be between '=' and 'Text_File.txt, but there is a formatting issue that invalidates it.)

Here are the sample contents of the daily updated 'Text_File.txt'. Fortunately, the position of the characters I'm need never change.

XXXX_XXXXX.txt:XXXX (XXXXXXXXXXXXXX:(none)): 01-25-16 05:26AM XXXXXXXXX XXXXXXX.zip

Then SET another variable to select the date and time information from that set text format.

Example: SET Export_date_time=%Directory_Contents:~30,17%

The character starting point and length were revised from what I thought the command line would identify as the contents.

Thanks to all from this (and other) forums for assistance in determining this solution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .