views:

21651

answers:

4

How you can read a file (text or binary) from a batch file? There is a way to read it in a binary mode or text mode?

A: 

Why would you possibly want to? What goal are you trying to accomplish? If you want to simply look for a string in a file use FindStr. If you want to do anything much more complicated than that, I would strongly suggest not using a bat.

EBGreen
I just want to know if this is posible
unkiwii
Oh, and you are right. If ANYONE want to do something complicated with a file i also recommend not to use a bat. This is experimental and to make some funny things DO NOT TRY THIS AT HOME! :)
unkiwii
+9  A: 

Under NT-style cmd.exe, you can loop through the lines of a text file with

FOR /F %i IN (file.txt) DO @echo %i

Type "help for" on the command prompt for more information. (don't know if that works in whatever "DOS" you are using)

devio
+6  A: 

You can use the for command:

FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k

Type

for /?

at the command prompt. Also, you can parse ini files!

johnstok
A: 

Reading and writing in binary is possible, but that will get ugly.

Coding With Style
Is it possible? ja.. I like to see that! :D
unkiwii