Solved How to set a variable to content of a text file?

March 28, 2015 at 22:15:00
Specs: Windows 7
I'm creating a server-based chat program, however I'm having a problem with storing the content of the text file into a variable. This is my code:
:start
cls
type "%coredir%\data\log.txt"
:load
rem NEED TO SET TXTNEW AND TXTOLD
if "%textold%"=="%textnew%" goto load
goto start

Any Ideas?

message edited by hacker202


See More: How to set a variable to content of a text file?

Report •


#1
March 28, 2015 at 23:46:06
I can't figure out your code but the answer to the thread subj is:

set /p var=< somefile

=====================

M2 Get custom script or take private lessons


Report •

#2
March 31, 2015 at 21:11:39
✔ Best Answer
:: set each line of file to a var 1 April 2015 11:09
::====== script starts here ===============
::
:: setmany.bat 2015-04-01 11:00:10.75
@echo off & setLocal enableDELAYedeXpansioN

set N=
:main
for /f "tokens=* delims= " %%a in (myfile) do (
set/a N+=1
set V!N!=%%a
)

for /L %%i in (1 1 !N!) do (
echo.!V%%i!
)
::====== script ends here =================

=====================

M2 Get custom script or take private lessons


Report •
Related Solutions


Ask Question