Set String from text file

David Carine January 29, 2009 at 09:09:43
Specs: Windows XP
Can anyone tell me how to SET a string from a text file in DOS. I need to run this in a batch file. The file contains just one line e.g.
Calculated TTF CRC: 00B2
If i can set a string to the data in the file, i can then extract the last 4 digits using the "%string:~n" to extract the CRC.

See More: Set String from text file

Report •


#1
January 29, 2009 at 17:13:06
To get the string into a variable (as you want it) this might work:

:: Code begins....
@echo off
cls

for /f "delims=*" %%A in ('type string.txt') do (
    set string=%%A
)

echo %string%
:: Code ends....


To immediately extract the crc try:

:: Code begins....
@echo off
cls

for /f "tokens=1-4" %%A in ('type string.txt') do (
      set crc=%%D
)

echo %crc%
:: Code ends....

Whichever way you choose - good luck.


Report •

#2
January 29, 2009 at 22:20:53
Sure, but not in DOS.


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

M2


Report •

Related Solutions


Ask Question