Computing.Net > Forums > Disk Operating System > Read text file into variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Read text file into variable

Reply to Message Icon

Name: besmith05
Date: January 31, 2008 at 20:34:17 Pacific
OS: XP
CPU/Ram: Intel
Product: ?
Comment:

I have a text file that contains a string like this:

C00000000940000000001SWT18A1101000

What I need to do is from within a batch file, read in the contents of the file and then get the value at a certain position like the character at position 15. I've been searching and searching and I can't find any examples and I'm a rookie at this stuff.

Thanks in advance for any help!




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: January 31, 2008 at 21:44:55 Pacific
Reply:

If i's XP [not DOS]:

::==
@echo off
setLocal EnableDelayedExpansion

set /p var=<my.txt
set var=!var:~14,1!
echo char 15 is !var!
::==



=====================================
If at first you don't succeed, you're about average.

M2



0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Read text file into variable

Read a text file into a batch pgm? www.computing.net/answers/dos/read-a-text-file-into-a-batch-pgm/8760.html

read first line from text file www.computing.net/answers/dos/read-first-line-from-text-file/15066.html

get file into variable www.computing.net/answers/dos/get-file-into-variable/12158.html