Computing.Net > Forums > Programming > reading body of text from batch

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.

reading body of text from batch

Reply to Message Icon

Name: francoom
Date: May 12, 2009 at 05:15:53 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Valerie (by Garibaldi)
Date: May 12, 2009 at 16:25:46 Pacific
Reply:

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...


0

Response Number 2
Name: francoom
Date: May 12, 2009 at 20:21:53 Pacific
Reply:

IT WORKED!!!

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

Thanks! :)


0

Response Number 3
Name: Valerie (by Garibaldi)
Date: May 13, 2009 at 00:47:48 Pacific
Reply:

Thanks for coming back to report your success.

Valerie.


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: reading body of text from batch

Batch file to extract lines of text from .ini www.computing.net/answers/programming/batch-file-to-extract-lines-of-text-from-ini/19089.html

Delete first line of text www.computing.net/answers/programming/delete-first-line-of-text/13312.html

Batch to del first x lines of text www.computing.net/answers/programming/batch-to-del-first-x-lines-of-text/16887.html