Computing.Net > Forums > Programming > Set String from text file

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.

Set String from text file

Reply to Message Icon

Name: David Carine
Date: January 29, 2009 at 09:09:43 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Wahine
Date: January 29, 2009 at 17:13:06 Pacific
Reply:

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.


0

Response Number 2
Name: Mechanix2Go
Date: January 29, 2009 at 22:20:53 Pacific
Reply:

Sure, but not in DOS.


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

M2


0

Sponsored Link
Ads by Google
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 Programming Forum Home


Sponsored links

Ads by Google


Results for: Set String from text file

Set word from text file as variable www.computing.net/answers/programming/set-word-from-text-file-as-variable/19634.html

remove string values from text file www.computing.net/answers/programming/remove-string-values-from-text-file/15756.html

reading lines from text file (java) www.computing.net/answers/programming/reading-lines-from-text-file-java/12276.html