Page 1 of 1

Loading a Single Line of a txt files into a Variable

Posted: 02 Sep 2007 06:39
by Rimal7
Hi,

I have an txt File that contains a single line of text, and I want to load the txt string from the TXT file into a DOS Batch variable then Concat the string to the section of the string that I need.

Filename: InvoiceNumber.txt

I have no idea where to start, could someone please help.

Thanks,



Rimal 7
DOS Batch Newbie

Posted: 07 Sep 2007 23:10
by DosItHelp
Rimal7,

To get the string from the file use the "for /f" command.

Code: Select all

REM The "for /f" command reads a line from a file
for /f "delims=" %%a in (InvoiceNumber.txt) do set "TxtFromFile=%%a"
REM Now concatenate as desired
set "txt=Hi, this is from the InvoiceNumber.txt file: %TxtFromFile%"
echo.%txt%


DosItHelp? :wink:

Loading from a TXT file

Posted: 10 Sep 2007 09:12
by Rimal7
Worked Beautifully

Thanks for your help,


Rimal 7