reading body of text from batch

May 12, 2009 at 05:15:53
Specs: Windows XP
I have a file named "test.txt" and I would like to get the content of test.txt in a batch file.

The content of test.txt is:
abcdefg
hijklmnop
qrstuvwxyz

I have this on the batch file:

pffile=test.txt
cls
binary.exe %pffile%

Where binary.exe is an executable file. My problem is that it interprets it as
binary.exe test.txt

What I want is to interpret it as:
binary.exe "abcdefghijhklmnopqrstuvwxyz"

Hope you can help me.


See More: reading body of text from batch

Report •


#1
May 12, 2009 at 16:25:46
One way - untested:

:: Code begins...
@echo off
cls

setlocal enabledelayedexpansion

for /f "delims=" %%1 in (test.txt) do (
    set pffile=!pffile!%%1
)
set pffile="%pffile%"

binary.exe %pffile%
:: Code ends...


Report •

#2
May 12, 2009 at 20:21:53
IT WORKED!!!

Thank you so much Gari!!! Your post is greatly appreciated!!!

Thanks! :)


Report •

#3
May 13, 2009 at 00:47:48
Thanks for coming back to report your success.

Valerie.


Report •

Related Solutions


Ask Question